View previous topic :: View next topic |
Author |
Message |
abq_guy
Joined: 26 Jan 2009 Posts: 13
|
How to store non-volatile data in runtime inside PIC |
Posted: Wed Feb 04, 2009 10:38 pm |
|
|
Hello Everybody,
I have a 16 bit ADC connected to the PIC18F8722 using SPI bus.
The first time the board will be powered On, I need to run a calibration routine on the ADC and then store some offset data inside the PIC itself, so that when the board is powered On after that, the PIC checks to see if the calibration data is present in the memory and uses it to read the ADC.
If the calibration data is not present ( first time it starts ), it prompts the user that the calibration data is missing from the PIC using UART to display on the hyperterminal.
How can I do this ? I cannot use an external EEPROm or any other external memory right now.
Thanks a lot,
abq_guy. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Feb 04, 2009 11:06 pm |
|
|
This program will give you some hints. Notice how the eeprom is
initialized to 0x00 at programming time with the #rom statement.
http://www.ccsinfo.com/forum/viewtopic.php?t=22109&start=17
Your code can call read_eeprom() to see if it's set == 0x00 at the
start of main(). If it's == 0x00, then you can call your calibration
routine, and set it to the CAL val (which is presumably non-zero).
Then later, when the PIC is powered-up again, it will read a non-zero
value in the eeprom and your code scan skip doing the CAL routine. |
|
|
abq_guy
Joined: 26 Jan 2009 Posts: 13
|
|
Posted: Thu Feb 05, 2009 2:20 pm |
|
|
PCM programmer wrote: | This program will give you some hints. Notice how the eeprom is
initialized to 0x00 at programming time with the #rom statement.
http://www.ccsinfo.com/forum/viewtopic.php?t=22109&start=17
Your code can call read_eeprom() to see if it's set == 0x00 at the
start of main(). If it's == 0x00, then you can call your calibration
routine, and set it to the CAL val (which is presumably non-zero).
Then later, when the PIC is powered-up again, it will read a non-zero
value in the eeprom and your code scan skip doing the CAL routine. |
Thanks PCM_programmer. I will try it and let you know.
Abq_guy |
|
|
|