View previous topic :: View next topic |
Author |
Message |
jmaudley
Joined: 01 Feb 2011 Posts: 32 Location: 53
|
EEPROM write/read problem (losing contents) |
Posted: Thu Jun 20, 2013 4:10 am |
|
|
Hi,
I'm having a problem writing and reading EEPROM contents.
After a write, it will read the correct value back for a few reads then it loses the contents and returns 0xff.
I had the problem earlier in the development and after updating my compiler to V5.006 it seemed to go away but it's back again.
This my simplified code (sorry still not quite sure how to post code so it's a cut and paste):
Code: |
#include <16f877a.h>
#fuses HS,NOLVP,NOWDT,PUT
#use delay(clock=20M, crystal)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, timeout=10, errors, stream=sbc)
#define COM_BSY PIN_C2
#define DAISY_ENA PIN_E1
#define OPEN_SBC_COM output_low (DAISY_ENA);delay_ms (10); //for debug puposes
void main(void)
{
OPEN_SBC_COM; //enables com port
int8 value;
delay_ms (10000); //power up delay
fprintf (sbc,"writing to EEPROM\r");
write_eeprom (0xe5,0xa3);
delay_ms (1000);
while(true)
{
//read back contents
value=read_eeprom (0xe5);
fprintf (sbc,"value=,%x\r",value);
delay_ms (1000);
}
} | I've changed memory locations - same result.
Changed chip just in case I killed a memory cell - same result.
Any assistance would be greatly appreciated. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Thu Jun 20, 2013 4:28 am |
|
|
Check with your programmer, what chip revision you have.
There is a really nasty bug with the B0 revisions of this chip, that basically means it can sometimes do completely unexpected things, if running over 4MHz.
It is affected by the code layout, position, board itself, etc. etc., with no 'known pattern', and just results in code running wrong. It only applies to revision B0, but if you accidentally had a few of these, it could be your problem...
Best Wishes |
|
|
jmaudley
Joined: 01 Feb 2011 Posts: 32 Location: 53
|
Working at the moment |
Posted: Thu Jun 20, 2013 6:03 am |
|
|
Firstly a quick update:
I'm using the ICD-U64 programmer.
Following your suggestion I opened CCS load and started to look for target details.
I couldn't find anything looking like the chip rev.
Whilst looking for this I noticed the file status was displaying CORRUPT.
Not sure why this happened to two different test programs but now that the hex files are GOOD it's corrected the issue.
Can you clarify how I check the chip rev. Is it on the chip marking? Is it displayed in CCS load UI?
For the moment I'm running again but not sure if I've fully got to the bottom of this one.
Thank you for your assistance.
I work alone and I really appreciate people willing to share their knowledge. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Thu Jun 20, 2013 7:13 am |
|
|
It's in the configuration data.
Location 2006. In binary: 001110010xxxx
Where 'xxxx' is a code representing the revision. 0001 for the B0 revision.
Best Wishes |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Thu Jun 20, 2013 9:39 am |
|
|
BTW: everything the 16f877x can do
the 16f887 can do
only BETTER and cheaper as well
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jun 20, 2013 10:48 am |
|
|
Describe your board and the external circuits. The 16F877A must have
100 nF (0.1 uF) ceramic capacitors between Vdd and Vss, on both sides of
the chip and placed close to the pins. If you leave these caps off the
board, the 16F877A will very likely be unreliable in its operation. |
|
|
|