Try this and lets see how it goes
there are better ways of doing this but i am quite in a rush
Toni
' Hardware Defines
' ----------------
SCL VAR PORTC.3 ' I2C clock pin
SDA VAR PORTC.4 ' I2C data pin
'
' Software Defines
' ----------------
' ** Declare the Variables **
Temp VAR WORD ' General Purpose
Data_Out VAR byte ' Data read from the Eeprom
Data_In VAR byte[4] ' Data written to the Eeprom
address VAR WORD ' Address
'
' Initialise Hardware
' -------------------
ADCON1=7
TRISA=%00000000
TRISB=%00000000
TRISC=%10000000
TRISD=%00000000
Pause 1000
LCDOut I,Clr:Pause 30
LCDOut I,Line1+2," 24C128 TEST "
LCDOut I,Line2+2,"..Power On.. !!"
Pause 1000 ' Allow Time for user to view
Data_Out=0:
Data_In[0]=$EA
Data_In[1]=$FD
Data_In[2]=$12
Data_In[3]=$8A
'WRITE SUB
'=======
For address = 0 TO 3 ' Loop 16 times
I2CWrite SDA,SCL,%10100000,address, [Data_In[address ]] ' Write each 2 location
Pause 10 ' Delay 10ms after each write
Next address
loop:
'READ SUB
'=======
HSerout [" send : "]
For address = 0 TO 3 ' Loop 16 times
LCDOut I,Clr:Pause 30
I2CRead SDA,SCL,%10100000,address,[Data_Out] ' Read 2 locations in a row
LCDOut I,Line1+2," Eprom Values :"
if address < 3 then
LCDOut I,Line2+2,#address,": ",hex1 Data_Out ' Display Eprom Data
HSerout [HEX1 Data_Out]
else
Data_Out=Data_Out >>4
LCDOut I,Line2+2,#address,": ",hex Data_Out ' Display Eprom Data
HSerout [HEX Data_Out]
endif
Pause 1000
Next address
HSerout [10,13]
GoTo loop
End




Bookmarks