eeprom externa en mikrobasic

Buenos dias, escribo por mi desesperacion y en vusca de respuestas, porque no se que hacer, he realizado el programa de la eeprom que pone en los ejemplos y lo que lee desde luego no es lo que le mando escribir.
Este es mi codigo


dim GLCD_DataPort as byte at PORTD

dim GLCD_CS1 as sbit at RB0_bit
GLCD_CS2 as sbit at RB1_bit
GLCD_RS as sbit at RB2_bit
GLCD_RW as sbit at RB3_bit
GLCD_EN as sbit at RB4_bit
GLCD_RST as sbit at RB5_bit

dim GLCD_CS1_Direction as sbit at TRISB0_bit
GLCD_CS2_Direction as sbit at TRISB1_bit
GLCD_RS_Direction as sbit at TRISB2_bit
GLCD_RW_Direction as sbit at TRISB3_bit
GLCD_EN_Direction as sbit at TRISB4_bit
GLCD_RST_Direction as sbit at TRISB5_bit

dim dato as byte
dim ddato as string[3]

main:
trisa=0
trisb=0
trisc=0
trisd=0
trise= %111
adcon0=%10000000
adcon1=%10001110
porta=0
portb=0
portc=0
Glcd_Init() ' Inicializamos la pantalla
Glcd_Fill(0)
delay_ms 50
glcd_write_text("Inizializando memoria",0,1,1)
delay_ms 2000
I2C1_Init(100000) ' initialize I2C communication
I2C1_Start() ' issue I2C start signal
I2C1_Wr(0xA2) ' send byte via I2C (device address + W)
I2C1_Wr(2) ' send byte (address of EEPROM location)
I2C1_Wr(0x20) ' send data (data to be written)
I2C1_Stop() ' issue I2C stop signal

Delay_ms 1000

I2C1_Start() ' issue I2C start signal
I2C1_Wr(0xA2) ' send byte via I2C (device address + W)
I2C1_Wr(0x02) ' send byte (data address)
I2C1_Repeated_Start() ' issue I2C signal repeated start
I2C1_Wr(0xA3) ' send byte (device address + R)
Dato = I2C1_Rd(0) ' Read the data (NO acknowledge)
I2C1_Stop() ' issue I2C stop signal

bytetostr(dato,ddato)
glcd_write_text(ddato,50,3,1)

end.


Cuando lee en la glcd me muestra 162 que es la A2 en Hexadecimal. Agradezco cualquier idea.
 
Atrás
Arriba