|
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.
------- temp var byte promin var byte address var word temp = 0 address = 0 cbit var byte cbit =%10100000
SEROUT s_out, i38400, [0, "starting", 13]
FOR address = 0 to 100 cbit.bit1=address.bit8 cbit.bit2=address.bit9 i2cout p14,p15,outerror,cbit,address,[temp] pause 25 temp=temp+1 next
for address = 0 to 100 cbit.bit1 = address.bit8:cbit.bit2=address.bit9 i2cin p14,p15,inerror,cbit,address,[promin] serout s_out, i38400, [dec address," Memory location = ",dec promin, 13] next
goto all_done
outerror: serout s_out, i38400, ["We had a write error", 13] goto all_done
inerror: serout s_out, i38400, ["We had a read error", 13]
all_done: END ---------
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.
------ temp var byte promin var byte address var word temp = 0 address = 0 cbit con %10100000
SEROUT s_out, i38400, [0, "starting", 13]
FOR address = 0 to 100 i2cout p14, p15, outerror, cbit, [address.byte1, address.byte0, temp] temp=temp+1 pause 25 next
FOR address = 0 to 100 i2cout p14, p15, outerror, cbit, [address.byte1, address.byte0] i2cin p14, p15, inerror, cbit, [promin] serout s_out, i38400, [dec address," Memory location = ",dec promin, 13] next
goto all_done
outerror: serout s_out, i38400, ["We had a write error", 13] goto all_done
inerror: serout s_out, i38400, ["We had a read error", 13]
all_done: end ------
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
i2cout p14, p15, outerror, cbit, [address.byte1, address.byte0] pause 25 i2cin p14, p15, inerror, cbit, [promin]
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.
|