Hello,
I have read MELANIE'S FAQ (I2CRead & I2CWrite not working as expected) but my code always not working. Normaly I must have minute =12 but it give me 0
I am using 16F877A and 24LC64 (pin1, 2, 3, 4, 7 to the ground ; 8 to 5v ; SDA and SDL to 16F877A).
Any idea ?
---------------------------------------------------
My code :
DEFINE OSC 4
Include "modedefs.bas"
asm
ERRORLEVEL -306, -302
endasm
DEFINE LCD_DREG PORTD
DEFINE LCD_RSREG PORTA
DEFINE LCD_RWREG PORTA
DEFINE LCD_EREG PORTA
DEFINE LCD_RSBIT 2
DEFINE LCD_RWBIT 1
DEFINE LCD_EBIT 0
DEFINE LCD_DBIT 0
DEFINE LCD_BITS 8
DEFINE LCD_LINES 4
RETRO VAR PORTA.3
SCL VAR PORTC.3
SDA VAR PORTC.4
minute VAR word
adr var word
ADCON1=7
TRISA=%11100000
TRISB=%11110000
TRISD=%11110000
i2cdevice CON %10100000
High RETRO
MAIN:
adr=1
I2CWRITE PORTC.4,PORTC.3,i2cdevice,adr,[12]
pause 10
i2CREAD PORTC.4,PORTC.3,i2cdevice,adr,[minute]
pause 10
LCDOUT $FE,1
LCDOUT $FE,192,dec minute,"min "
end
Bookmarks