|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Re: Saving a variable in between runs.
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 |
|
#2
|
|||
|
|||
|
Re: Saving a variable in between runs.
Quote:
I'm using it to store p1_x values that a gyro calculated to make it go strait. Then next time I hit forward on the joystick it would start off with the calculated p1_x value instead of default 127. This (hopefully) will eliminate any beggining turning while the gyro is building up error. Last edited by colt527 : 15-09-2004 at 16:49. |
|
#3
|
||||
|
||||
|
Re: Saving a variable in between runs.
Quote:
|
|
#4
|
|||||
|
|||||
|
Re: Saving a variable in between runs.
Quote:
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. Last edited by Mark McLeod : 15-09-2004 at 17:41. |
|
#5
|
||||
|
||||
|
Re: Saving a variable in between runs.
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |