View Single Post
  #1   Spotlight this post!  
Unread 15-09-2004, 17:20
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,820
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Saving a variable in between runs.

Quote:
Originally Posted by pi_guy578
Am I mistaken by saying if you initialize a static variable such as static int inBetween and it will store the varaible into the program, instead of the RAM. That is the ANSI C standard AFAIK, I'm not sure if its different on PIC chips... Can someone clarify?

Jake
There are three basic types of storage available to you on the PIC.

1) "static int x;" uses RAM or data space just as "int x;" does. You can change the value of x from within your program while it's executing (e.g. "x=y+2;"), but the value only lasts as long as the RC is on. All data is lost or returns to initialized values when the RC is turned off or reset.

2) "rom const int x=10;" uses ROM or program space. You cannot change the value of x from within your program as it's running (the compiler will reject "x=y+2;" as an error). The value at program load is permanent and unchanging, only by downloading a new program can x be modified. I believe this is what you were thinking of.

3) EEPROM requires special read/write commands to access as noted above. The value can be changed from within the program while it's running and the latest value is still there after the RC has been turned off or reset. This retention of a changable value is the reason people go to so much trouble to use the EEPROM r/w commands.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 15-09-2004 at 17:41.