-
I2c
Can somebody help me please with some sample code. I have not used I2C before and I need to store a variable (B28), with a value between 1-9999 in an external memory EEPROM device, 24A65. All of the device address pins are held down to ground. My code does not work, please can you help.
HOME1:
I2CREAD PORTB.4,PORTB.5,%10100000,#B28
B28 = B28 + 1
PAUSE 500
I2CWRITE PORTB.4,PORTB.5,%10100000,#B28
LCDOut $FE,1,#B28
PAUSE 500
GOTO HOME1
Thanking you in anticipation.
Mark in Spain
-
Mark,
try the following:
B28 var word
Adr VAR Byte
B28=1245 ' Value to write
Adr=0 ' EEPROM Location to write to
I2CWRITE PORTB.4,PORTB.5,%10100000,Adr,[B28]
Pause 50
I2CREAD PORTB.4,PORTB.5,%10100000,Adr[B28]
PAUSE 50
LCDOut $FE,1,DEC5 B28
PAUSE 1000
For reference see PBP Manual Section 5.34 & 5.35
regards
Ralph
-
Thanks Ralph, now I understand.