View previous topic :: View next topic |
Author |
Message |
cerr
Joined: 10 Feb 2011 Posts: 241 Location: Vancouver, BC
|
EEPROM corruption |
Posted: Fri Mar 16, 2012 10:54 am |
|
|
Hi,
I'm fighting with EEPROM corruption if I power up and down my system multiple times. Looking at the power up, it's quite ugly and choppy for about 100ms and I believe that that might be the cause of the issues we're seeing. I found this from Microchip:
http://support2.microchip.com/KBSearch/KB_StdProb.aspx?ID=SQ6UJ9A00DZERwhich says
Quote: | separate the "write enable" section of code, from the "write to EEPROM" section. |
Now in order to do that, I would need to write some inline assembly. How can I do this?
Also, I already set the EEADR and EEADRH registers after read_eeprom() and write_eeprom() to an unused position to avoid spurious writes on power down to corrupt the address where EEADR is pointing at. (developed my own eeprom w/r functions using CCS' eeprom functions inside).
Any other hints or suggestions?
Assistance & ideas are appreciated!
Ron |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Mar 16, 2012 12:18 pm |
|
|
Quote: |
Looking at the power up, it's quite ugly and choppy for about 100ms and
I believe that that might be the cause of the issues we're seeing.
|
Disconnect (unsolder) your on-board power supply and substitute a
power supply that starts up cleanly. Possibly use a bench power supply.
Test it and see if you still get the problem.
Quote: |
Now in order to do that, I would need to write some inline assembly.
How can I do this?
|
Set the .LST file format to Symbolic mode, compile a small test program
that uses the CCS write_eeprom() function and look at the .LST file.
You will see how they do it. This thread discusses how to look at the
.LST file code for the eeprom routines:
http://www.ccsinfo.com/forum/viewtopic.php?t=38718&start=15
You don't have to write in assembly, though you could if you wanted to,
by using #asm and #endasm. Instead, just write the code at one level
above assembly. Use #byte and #bit statements and declare the registers
and bits used with the internal eeprom. Then write C code to talk to those
registers and bits.
But before you do any of this, it might help to read all previous threads
on eeprom corruption problems in the forum archives. Do a search for this:
Set it to: Search for all terms
This thread shows a problem where the user wrote his own low
http://www.ccsinfo.com/forum/viewtopic.php?t=38718&start=15 |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9170 Location: Greensville,Ontario
|
|
Posted: Sat Mar 17, 2012 5:35 am |
|
|
Fix the hardware first, don't rely on a software 'patch'!
No amount of clever code will truly cure the 'ugly' power supply problem.
While it might in the short term, sooner or later, that 'ugly' power supply will come back and do real damage.Destroying one PIC on your bench is no big deal, having it destroy a customer's 37 systems is really,really bad news. |
|
![](templates/subSilver/images/spacer.gif) |
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Sat Mar 17, 2012 9:27 am |
|
|
How does your "corruption" manifest??
Do you add a checksum or CRC to EEPROM data when you store it ?
Or are you simply saving data and reading it back w/o any validity check in the code you used?
What are the circumstances in your code that cause an intentional write to EEPROM?? |
|
![](templates/subSilver/images/spacer.gif) |
|