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 write/read problem (losing contents)

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



Joined: 01 Feb 2011
Posts: 32
Location: 53

View user's profile Send private message AIM Address

EEPROM write/read problem (losing contents)
PostPosted: Thu Jun 20, 2013 4:10 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jun 20, 2013 4:28 am     Reply with quote

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

View user's profile Send private message AIM Address

Working at the moment
PostPosted: Thu Jun 20, 2013 6:03 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jun 20, 2013 7:13 am     Reply with quote

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

View user's profile Send private message AIM Address

PostPosted: Thu Jun 20, 2013 9:39 am     Reply with quote

BTW: everything the 16f877x can do
the 16f887 can do
only BETTER and cheaper as well

Very Happy Very Happy Very Happy
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jun 20, 2013 10:48 am     Reply with quote

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