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

EEPROM data after power up

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



Joined: 22 Aug 2006
Posts: 18

View user's profile Send private message

EEPROM data after power up
PostPosted: Mon Apr 30, 2007 10:08 am     Reply with quote

Hello there,

I'm having a problem reading data from the EEPROM after power up.

Some background info:
I store some data into the EEPROM, and store a CRC of the data. When the program starts, I read the EEPROM, compute the CRC, and checks it against the stored CRC. The problem is that sometimes the CRC don't match, and I would like to find out why.
I can see five reasons:
- the EEPROM is damaged. Unlikely as the PICs are new.
- the stored CRC is incorrect. Unlikely.
- data are not written properly into the EEPROM. Unlikely as I read each data after being written.
- there is a power cut while I'm writing data to the EEPROM. That could cause a problem, but again I don't think this is happening.
- Data are not being read properly after the power up sequence, and the CRC don't match. That looks like the most likely scenario, however I use the Power Up Timer, and wait 5ms before reading data from the EEPROM.

What do you think is causing the CRC to do not match?

I'd also like to mentioned that I cannot reproduce this bug at will so it's really difficult to debug.

Thanks for your help,

Christophe D.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Apr 30, 2007 12:20 pm     Reply with quote

Post the PIC and the compiler version.

The PIC may have an errata on the eeprom.
ch_dupre



Joined: 22 Aug 2006
Posts: 18

View user's profile Send private message

PostPosted: Tue May 01, 2007 2:12 am     Reply with quote

I'm using PIC 18F4550. I've checked the errata and there is nothing mentioned.
The compiler is V4.033.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue May 01, 2007 2:51 am     Reply with quote

I assume you are storing an array of data. Let's say it's 16 bytes.
Then maybe you have one more byte for the CRC.

I would modify the program to do some testing. I would fill the array
with the same data each time. The array element would be set to the
index value. ie. 0,1,2,3,4,5,6,7,8,9,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F.
I would set the CRC byte to 0x55. (Don't calculate it. Use 0x55).
Also, comment out any other code that reads or writes to the eeprom.
Then I would add a for() loop and a printf statement to display all the
array data and the CRC byte, one second after power-up.

Then just sit there and turn the power to the board on and off every
few seconds for a few minutes. Watch the terminal window and look
to see if it fails. If it does fail, then you can see if a specific eeprom
address is always the one that fails. You can also try other tests, such
as waiting for 100 ms after power-up (instead of 5 ms) before you read
the eeprom.

You can do a test in which you don't ever write to the eeprom (once it's
setup as listed above) and you only read from it. Then do the power
on and off tests. This will test if just reading from it and turning the
power on/off is causing a failure.

Keep your normal program in the test program. But don't have the
normal program use data from the eeprom. Get the data for the normal
program from a 'const' array stored in Flash ROM (not eeprom). Just
invent some data that will be suitable to keep the normal program
running. The purpose here is to separate the normal program from
the testing of the eeprom, but still, to keep the normal program in the
PIC, so that the running environment won't be changed too much.

In many of your ideas you have said "not likely", but you haven't really
proven it to be 100% true until you do more detailed testing. You need
to design test programs that will look at just one aspect of the eeprom
operation. Then do repeated tests on each aspect.

There's a question about writing during power-down. Write a test
program (while keeping your normal code in it) that writes a fixed
set of values to the eeprom but only do it, let's say, 2 seconds after
you apply power to the board. Then when you test it, wait 5 seconds
before you turn the power off. This tests writing to the eeprom but
avoids doing writing while the board is powered-down.
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