Go to Post you know you have overdosed to first when while you are reading all of these things, you can smile and say "oh yeah, i miss doing that" and then, you start to tear up and scream "I MISS FIRST!!!" - amanda547 [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #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,756
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.
  #2   Spotlight this post!  
Unread 16-09-2004, 18:29
pi_guy578 pi_guy578 is offline
Programmer/Electrician
AKA: Jake
FRC #0578 (Blue Lightning)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Fairport
Posts: 48
pi_guy578 has a spectacular aura aboutpi_guy578 has a spectacular aura about
Send a message via AIM to pi_guy578
Re: Saving a variable in between runs.

Quote:
Originally Posted by Mark McLeod
"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.
Whoops, my mistake, a static variable stays initialized between function calls but not neccessarily program runs.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
MPLAB Variable Simulator? Chris_Elston Programming 3 18-02-2004 12:08
Interrupt Handlers and Variable Scope kaszeta Programming 2 14-02-2004 18:30
variable? manodrum Programming 11 01-04-2003 17:20
Dashboard programs and the char variable Ian W. Programming 13 26-06-2002 02:07
what teams have a variable transmissions? Greg Perkins Technical Discussion 4 06-03-2002 06:10


All times are GMT -5. The time now is 20:04.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi