View previous topic :: View next topic |
Author |
Message |
Seaborgium
Joined: 23 Jul 2012 Posts: 14
|
Avoiding Overwriting Program in Program Memory |
Posted: Mon Jul 23, 2012 6:54 pm |
|
|
Hi, I'm working with the PIC16LF1503 and need to store an I2C slave address (just one or two bytes) in non-volatile memory, so that it isn't lost when the PIC powers down. Since this chip doesn't have EEPROM, and a chip with EEPROM would be more expensive, I'm thinking about storing the data in the program memory.
However, my concern is that I might overwrite the program itself, leading to disastrous consequences. How do I know what spaces are "free" in the program memory? Is the program stored in one continuous length starting from address 0, therefore allowing me to store stuff at the back end of program memory (my program isn't large and I should have plenty of room)?
I'm using PCWHD version 4.133, and this will be implemented on real hardware, on the off chance that that helps. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Jul 23, 2012 7:38 pm |
|
|
You can reserve flash memory for your own use with the #org statement:
http://www.ccsinfo.com/forum/viewtopic.php?t=21818
Look at the .LST file to see where the compiler puts the program and
other data. You can also look at the Program Memory window in the
View menu in MPLAB. For the 16F1503, you can use the end of Flash
memory for your own data. But use the #org statement to reserve it. |
|
|
Seaborgium
Joined: 23 Jul 2012 Posts: 14
|
|
Posted: Tue Jul 24, 2012 11:47 am |
|
|
Oh, I see. Thank you very much! |
|
|
|