I am developing a weather station logging system uses a 16F877 and should write 16 bytes of daily data to a 24LC512 EEPROM. Using I2C, I have a DS1307 (which works fine) connected on the same bus as the 24LC512. However, I cannot write or read succesfully to the EEPROM at all. the 3 address pins on the 512 are grounded. After trying unsuccessfully to write & read in page mode, I went back to the "Really simple" example in the PBP handbook, which I still cant get to work - instead of reading a 6 back, I get 255
Code below:
'27LC512 READ/WRITE Test
'DS1307 works fine on SCL and SDA pins below.
'24LC512 is in parallel with DS1307
SCL pin VAR PORTC.2
SDApin VAR PORTC.3
B2 var byte
'24LC512 MSB is device code. LSB is device address, all address pins grounded
cont con %10100000
'Writetest:
Lcdout $fe,1:Pause 500
Lcdout $fe,$80,"Mem read/write test"
I2cWrite SDAPin,SCLPin,cont,%00001111,[6] 'Write decimal 6 to address 15
pause 20 'Allow time for write to finish
''----------------------------| Now read it back |--------------------------
I2cread SDAPin,SCLPin,cont,%00001111,[b2] 'Read data at address 15
lcdout $fe,$C0,#B2:Pause 50
Idle:goto Idle
End
I Get 255 returned in B2 instead of decimal 6
Any help gratefully received
Angus Anderson
Bookmarks