CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Retrieving variables contents after power off.

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
uni_student



Joined: 01 Aug 2007
Posts: 38
Location: AUckland, NEW ZEALAND

View user's profile Send private message Send e-mail MSN Messenger

Retrieving variables contents after power off.
PostPosted: Tue May 25, 2010 7:33 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue May 25, 2010 8:35 pm     Reply with quote

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

View user's profile Send private message Send e-mail MSN Messenger

PostPosted: Wed May 26, 2010 3:17 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed May 26, 2010 4:41 am     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Wed May 26, 2010 6:15 am     Reply with quote

The address can be determined automatically:
Code:
#rom getenv("EEPROM_ADDRESS")={

_________________
Andrew
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group