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

How to store non-volatile data in runtime inside PIC

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



Joined: 26 Jan 2009
Posts: 13

View user's profile Send private message

How to store non-volatile data in runtime inside PIC
PostPosted: Wed Feb 04, 2009 10:38 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Feb 04, 2009 11:06 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Feb 05, 2009 2:20 pm     Reply with quote

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
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