I could use some help with my code to write and read to a 24LC256 EEPROM. I've successfully intregrated I2C for a DS1307 RTC, HMC6352 and analog LM34 outputting to a 2X16 LCD for a nifty time/temp/compass heading console so the 24LC256 should be a piece of cake but nooo, not yet.
Using the following simple routine to learn to use the 24LC256, it reads the LM34 or a fixed number, writes it to the EEPROM, reads the EEPROM contents back and using DEBUG everything displays on the PICAXE editor. However, reading the EEPROM gets FF in b8 & b9 as the result. The 24LC256 documentation says FF will be returned if the command is not successful.
I've looked at other code examples/tutorials/forum postings that were not specific to this EEPROM and tried many variations of the following code initializing the EEPROM FAST, Slow, byte and word. the EEPROM address is %1010000 so I've also tried setting the R/W bit in the address word for example 10100000 for write and 10100001 for read, no luck.
My goal is to learn to use the EEPROM to store my clock/temperature and heading just for the learning experience.
20X2, 5V operation, 4.7k pullup resistors on SCL/SDA pins on a proto board. Other I2C devices are removed from the board.
Wonder if I can get some help. Thanks Bill
20X2 with LM34 and 24LC256 EEPROM
Using the following simple routine to learn to use the 24LC256, it reads the LM34 or a fixed number, writes it to the EEPROM, reads the EEPROM contents back and using DEBUG everything displays on the PICAXE editor. However, reading the EEPROM gets FF in b8 & b9 as the result. The 24LC256 documentation says FF will be returned if the command is not successful.
I've looked at other code examples/tutorials/forum postings that were not specific to this EEPROM and tried many variations of the following code initializing the EEPROM FAST, Slow, byte and word. the EEPROM address is %1010000 so I've also tried setting the R/W bit in the address word for example 10100000 for write and 10100001 for read, no luck.
My goal is to learn to use the EEPROM to store my clock/temperature and heading just for the learning experience.
20X2, 5V operation, 4.7k pullup resistors on SCL/SDA pins on a proto board. Other I2C devices are removed from the board.
Wonder if I can get some help. Thanks Bill
20X2 with LM34 and 24LC256 EEPROM
Code:
init:
let adcsetup = %0000000000100000 ;set B.3 or ADC5 for LM34
hi2csetup i2cmaster, %11000000, i2cslow, i2cbyte ;Init PICAXE for 24lc256
main:
b0=0
b1=0
readadc10 b.3,w0 ;read LM34 value
debug ;b0 reflects LM34 value(s)
pause 1000
W1 = $0000 ;eeprom mem addr 0000
hi2cout w1,(b0,b1) ;write LM34 w0 to eeprom
pause 20
debug
pause 1000
b8=0
b9=0
hi2cin w1,(b8,b9) ;read from eeprom mem addr 0000
pause 20
sertxd("Temp=", b8,b9,13,10)
debug
pause 2500
;OBSERVE FF in b8 and b9 and LM34 output is OK in b0
goto main