I found three methods to store data at a particular location in program memory of pic microcontroller, when working with xc8 compiler. The three macros/directives that i found were
- __section()
- __at()
- ‘@’ qualifier
The first two methods are little complex and difficult to manage, while the third one the ‘@’ qualifier is easy to manage and use. Before using the ‘@’ qualifier one should first check the program memory banks addresses range of the pic microcontroller that he is using. I am using pic16f877 microcontroller, its program memory address range is from 0x0000 to 0x1FFF. The word size is 14 bits and memory size is 8 KB.
I want my code to start at program memory location/address 0x200. To do so i placed the ‘@’ qualifier at the end of the main function. See the above main function initialization. At the end of the closing brackets i placed the @ qualifier with the program memory address where i want my code to be placed in flash/rom. In the main function i have two for loop functions, generating a random delay.
|
int main(int argc, char** argv) @ 0x200 {}
I recommend to chose the program memory last/bottom address for placing your code. Do not pick the address from in between or starting memory address. Make the code stream line. Jumping at different address will create mess and increase latency.
void main() @ 0x100 {}
More tutorial on placing data at specific location/address in ram of pic microcontroller
Filed Under: Microcontroller Projects, PIC Microcontroller
Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.