View previous topic :: View next topic |
Author |
Message |
uni_student
Joined: 01 Aug 2007 Posts: 38 Location: AUckland, NEW ZEALAND
|
Retrieving variables contents after power off. |
Posted: Tue May 25, 2010 7:33 pm |
|
|
Hi, trying to store a value that changes into a variable, int mode; , switch off power to pic, and turn back on and retrieve the last value that was in that variable. Does declaring int mode; always store the variable in same space of memory every time switched on? How do i allocate to known part of memory if not the case? Cheers |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue May 25, 2010 8:35 pm |
|
|
This example show how to save a variable in internal eeprom and
restore it upon power-up.
http://www.ccsinfo.com/forum/viewtopic.php?t=22109&start=17
However, remember that internal eeprom has a limited number of
writes (lifespan). For the 16F877, the limit is 100K. In the example
in that link, the number of write operations will be relatively small. |
|
|
uni_student
Joined: 01 Aug 2007 Posts: 38 Location: AUckland, NEW ZEALAND
|
|
Posted: Wed May 26, 2010 3:17 am |
|
|
Thanx for reply,
in the line
Code: | #ROM 0x2100 = {0x00} |
how do you determine the rom address (0x2100)? Is this chosen randomly or that value for a reason? |
|
|
jbmiller
Joined: 07 Oct 2006 Posts: 73 Location: Greensville,Ontario
|
|
Posted: Wed May 26, 2010 4:41 am |
|
|
Each microcomputer has a 'memory map' that defines where what type of memory is located. The datasheets describe it in detail.EACH series of chips will be different(RAM,ROM, EEPROM, Peripherals,etc.)
Random Access Memory is volatile,used for dynamic variables...
Read Only Memory is programmed ONCE during the 'burning 'process'...
Electricallly Erasable program Memory can be reprogrammed when the program is running.....
Peripherals include all the 'I/O ports' and modules(timers,config locations,etc.) |
|
|
andrewg
Joined: 17 Aug 2005 Posts: 316 Location: Perth, Western Australia
|
|
Posted: Wed May 26, 2010 6:15 am |
|
|
The address can be determined automatically: Code: | #rom getenv("EEPROM_ADDRESS")={ |
_________________ Andrew |
|
|
|