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 CCS Technical Support

EEPROM will always read, but not always write.

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







EEPROM will always read, but not always write.
PostPosted: Wed Jul 21, 2004 1:57 pm     Reply with quote

I'm having a wierd problem. I can always read the EEPROM but not always write it. I'm positive that the ext_eeprom_write functions are being called. Anyone have any ideas? I can post code if it will help. I'm compiling on 3.091

Nick
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Wed Jul 21, 2004 2:07 pm     Reply with quote

Writing takes time. Are you sure you are waiting long enough?
_________________
The search for better is endless. Instead simply find very good and get the job done.
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Wed Jul 21, 2004 2:13 pm     Reply with quote

When attempting consecutive writes the prior burn may be incomplete and cause the following write to be rejected. check the busy flag to be sure.
Nick
Guest







PostPosted: Wed Jul 21, 2004 2:37 pm     Reply with quote

thank you, that sounds like the problem.. consecutive writes.

Nick
Nick
Guest







PostPosted: Wed Jul 21, 2004 2:45 pm     Reply with quote

I did a help file search for busy flag and didnt pull up anything. I did that on the new version and the old one. Where can I find information about the busy flag?

Nick
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Wed Jul 21, 2004 3:28 pm     Reply with quote

Do a search of the data sheet for the EEPROM you are using. You have to read it by I2C if I remember correctly.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jul 21, 2004 3:57 pm     Reply with quote

Quote:
Where can I find information about the busy flag?

This routine is from the 24256.c example file. The lines shown
in bold do "ack polling". For an explanation, see section 7.0 of
the 24LC256 data sheet on "Acknowledge Polling", at this link:
http://ww1.microchip.com/downloads/en/DeviceDoc/21203M.pdf

void write_ext_eeprom(long int address, BYTE data)
{
short int status;
i2c_start();
i2c_write(0xa0);
i2c_write(address>>8);
i2c_write(address);
i2c_write(data);
i2c_stop();
i2c_start();
status=i2c_write(0xa0);
while(status==1)
{
i2c_start();
status=i2c_write(0xa0);
}

}
Nick
Guest







PostPosted: Wed Jul 21, 2004 4:08 pm     Reply with quote

after some more testing it looks like the problem is that the data is wrapping.

for example

sending
10000000000121 is fine but


1000000000012131 ends up like this
13100000000121


the data wraps to the fron, but the eeprom is not even close to being filled.

Nick
Nick
Guest







PostPosted: Wed Jul 21, 2004 4:21 pm     Reply with quote

FF is Last address on the EEPROM before it starts the wrap... btw there is alot of space left on the eeprom.

Nick
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jul 21, 2004 4:36 pm     Reply with quote

Some questions:

1. What is the part number of the EEPROM that you're using ?
(ie., 24LC256, 24C64, etc.)

2. What driver are you using ?
(ie., 24256.C from CCS, etc.)


Comments:
Notice in the function declaration of the routine that I just posted,
that the address is a 16-bit value. (In CCS, a long int is 16-bits).
void write_ext_eeprom(long int address, BYTE data)
The symptoms that you describe could occur if you passed only
an 8-bit variable to that function for the address.

Another possibility is that you could be using the EEPROM in Page Mode,
and if the page size was 256 bytes, then it would certainly wrap if you
sent more than that at one time.

To help you any further, we need to know what EEPROM you're using
and what driver you're using.
Nick
Guest







PostPosted: Wed Jul 21, 2004 4:46 pm     Reply with quote

I should kick myself in the butt for not giving that information in the previous post.


the eeprom is a 24LC32A, and the drive is one you posted awhile back. I found it using the search engine. I believe its for a 24C256. The reason I was using it was because the demo didnt have one, but now I have an 3.091 full version.

Thank you again for your help.

Nick
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jul 21, 2004 5:32 pm     Reply with quote

Vs. 3.091 comes with a 2432.c driver file. It's in this folder:
c:\Program Files\Picc\Drivers
That version of 2432.c has an 11 ms delay at the end of its
write routine. The 24LC32A is spec'ed at 5 ms max write time,
so you could edit the driver and reduce the delay to say, 6 ms.
After you get it working, you could add ack polling.

---

So, are you using that driver, or are you still using one that
you found on the net ? If you're using the 2432.c driver,
and you still have problems, then please post a short demo
program that calls the driver functions, and demonstrates
the problem.
Charlie U



Joined: 09 Sep 2003
Posts: 183
Location: Somewhere under water in the Great Lakes

View user's profile Send private message

PostPosted: Wed Jul 21, 2004 5:54 pm     Reply with quote

You mentioned that FF is the last address where it starts to wrap. This may be obvious, but are you aware that each consecutive write or page write to the 24LC32, is limited to 32 bytes, and can not cross a multiple of 32 boundary? You can start a consecutive write, where multiple bytes are transmitted in a single command, at any address, but the last byte can not go beyond the 32 byte boundary. As I recall, it will wrap to the beginning of the page and overwrite other data. Take a look and see if this is what you are experiencing.
Nick
Guest







PostPosted: Wed Jul 21, 2004 9:46 pm     Reply with quote

yup,that was the problem


I was using a INT in one part, swapped it out to a LONG INT and it runs!

Thanks!

Nick
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