Reading and Writing iButton DS1996L
SMurphy
Posts: 6
I'm using the following code with a Basic Stamp 2p to write and read information to a DS1996L iButton.
'WriteRom:
TA = $0000
tempVar1 = $55
tempVar2 = $66
OWOUT OWpin,OW_FERst,[noparse][[/noparse]SkipRom,WriteScratchpad,TA.LOWBYTE,TA.HIGHBYTE,tempVar1,tempVar2]
OWOUT OWpin,OW_FERst,[noparse][[/noparse]SkipRom,ReadScratchpad]
OWIN OWpin,OW_BERst,[noparse][[/noparse]TA.LOWBYTE,TA.HIGHBYTE,ES]
OWOUT OWpin,OW_FERst,[noparse][[/noparse]SkipRom,CopyScratchpad,TA.LOWBYTE,TA.HIGHBYTE,ES]
OWOUT OWpin,OW_FERst,[noparse][[/noparse]SkipRom,ReadMemory,TA.LOWBYTE,TA.HIGHBYTE]
OWIN OWpin,OW_BERst,[noparse][[/noparse]tempVar1,tempVar2]
DEBUG HEX2 tempVar1, " ", HEX2 tempVar2,CR
PAUSE 2000
When I print the variables at the end they come out as 'AB' and 'CC' instead of '55' and '66'.
I'm sure i'm missing something simple so if anyone has any ideas i'd be very grateful.
'WriteRom:
TA = $0000
tempVar1 = $55
tempVar2 = $66
OWOUT OWpin,OW_FERst,[noparse][[/noparse]SkipRom,WriteScratchpad,TA.LOWBYTE,TA.HIGHBYTE,tempVar1,tempVar2]
OWOUT OWpin,OW_FERst,[noparse][[/noparse]SkipRom,ReadScratchpad]
OWIN OWpin,OW_BERst,[noparse][[/noparse]TA.LOWBYTE,TA.HIGHBYTE,ES]
OWOUT OWpin,OW_FERst,[noparse][[/noparse]SkipRom,CopyScratchpad,TA.LOWBYTE,TA.HIGHBYTE,ES]
OWOUT OWpin,OW_FERst,[noparse][[/noparse]SkipRom,ReadMemory,TA.LOWBYTE,TA.HIGHBYTE]
OWIN OWpin,OW_BERst,[noparse][[/noparse]tempVar1,tempVar2]
DEBUG HEX2 tempVar1, " ", HEX2 tempVar2,CR
PAUSE 2000
When I print the variables at the end they come out as 'AB' and 'CC' instead of '55' and '66'.
I'm sure i'm missing something simple so if anyone has any ideas i'd be very grateful.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
DS1996 Test
Loading transfer array.
TA: 0
Writing to DS1996 scratchpad.
Reading from DS1996 scratchpad.
›onpr`
Has it anything to do with the iButton itself?
If I leave it alone for a few minutes and try again, it works fine another three times.
Has it anything to do with the scratchpad memory on the iButton. Does it have to be reset before you use it again?
DS1996 Test
Loading transfer array.
1234567890abcdefTA: 0
Writing to DS1996 scratchpad.
Reading from DS1996 scratchpad.
-> cdfhjlnpr`
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax