Ok, here is the issue. I have known good 24C04 and 24C32 EEPROMS. I have an older project that I used IDE with the 24C04 and it worked fine. Here is some test code for IDE that writes 0-100 to the first 100 memory locations then reads them back and displays them in the terminal window.

The above test returns the expected values (0-100) with the 24C04. However when using a 24C32, I don't get any write or read error, but I get a result of 255 for all memory locations.

Ok, so I look up some code examples here and they don't work with IDE, so I try Micro Studio. My original code does not work at all with BMS, so I use some of the examples I found and come up with this. I again write 0-100 to the first 100 memmory locations and then read it back and display it in a terminal window.

Now this code works fine with the 24C32, but not with the 24C04. I get a jump to the read error routine. If I leave off the read error check, I get incorrect values for the 24C04. So why the heck won't it work with both EEPROMS? And why does IDE with with the 24C04 and not the 24C32 and BMS works with the 24C32 and not the 24C04? How can I get it to work with both? If the same code won't work for both EEPROMS how can I get the 24C04 to work with BMS?

<edit>I can get rif of the 24C04 read error with BMS by putting a pause in between these lines

However, it still returns the wrong data on the reads. And I can verify that data is not being written correctly either because I have a stand alone eprom burner that lets me read/write the chips. If I program in all zeros and then run the program, I will get some random 'garbage' in the first couple of bytes and that is it.

You have it exactly. The first I2C eeproms were very small and they only used one byte addressing. Later they added more memory and started using the 3 address bits in the control byte(%10101XXX0) to expand the memory size to upto 8*256 bytes. Then they came out with 2 byte addressing. And there are even chips that have 2 byte addressing and use the 3 address bits in the control byte to expand that to upto 8 times 65536 bytes. All of this happened over a very long time and they did not make them backwards compatible. You have to know what chip you are talking to to do it write.

Yeah, I think I finally got it all sorted out. On the 24C04, I never used more than about 100 bytes or so, and I just now figured out that you have to change the control byte from %10100000 to %10100010 to switch to the second 256 byte bank. At least the newer larger sized ones seem to be more straight forward and the 3 control bits %1010xxx0 are used for addressing the chip it's self, and not the innards. Thanks.

Who is online

Users browsing this forum: No registered users and 0 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum