I need to write to and then read back from a 1-wire EEPROM.
I have an iButton DS1973 which has the same insides as a
standard 1-wire DS2433 4Kb EEPROM.
I have read the datasheet, tried without success, searched the PBP and other sites but no answer.
I just need an example on how to write 1 byte to an address on the EEPROM and then read it back again. This code I tried but doesn't work:
ADCON1=7 ' Set all Ports to Digital I/O
OPTION_REG.7=0 ' Enable weak PullUps
TRISB.0=0
MEM VAR BYTE
RESULT VAR BYTE[4]
iButton var PortD.2
START:
SEROUT2 PORTB.0,16416,["START",10,13] 'just to test the comms
'WRITE TO EEPROM
OWOUT ibutton,1,[$CC,$0F,$00]
OWOUT IBUTTON,1,[$54,$65,$73,$74] 'write characters "test"
OWOUT IBUTTON,1,[$CC,$FF,$A5]
PAUSE 25
'READ FROM EEPROM
OWOUT ibutton,0,[$CC,$F0,$00]
FOR MEM=1 TO 32
OWIN IBUTTON,0,[RESULT]
SEROUT2 PORTB.0,16416,[RESULT]
PAUSE 100
NEXT MEM
END
Can anyone tell me what I have done wrong?
Regards
Chris
Bookmarks