Shop OBEX P1 Docs P2 Docs Learn Events
Reading and Writing iButton DS1996L — Parallax Forums

Reading and Writing iButton DS1996L

SMurphySMurphy Posts: 6
edited 2005-10-18 20:39 in BASIC Stamp
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.

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-10-18 15:20
    I've attached an updated version of a test program provided by one of our OEM customers -- give it a try and see if it helps.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • SMurphySMurphy Posts: 6
    edited 2005-10-18 16:08
    The first couple of times I ran the program you sent me it was fine but since then i've been getting these results

    DS1996 Test

    Loading transfer array.

    TA: 0
    Writing to DS1996 scratchpad.

    Reading from DS1996 scratchpad.
    ›onpr`
    1280 x 960 - 608K
  • SMurphySMurphy Posts: 6
    edited 2005-10-18 16:11
    I've just tried it again and it works for the first three times and then fails

    Has it anything to do with the iButton itself?
  • SMurphySMurphy Posts: 6
    edited 2005-10-18 16:36
    Just tried again. Works for three times and then gives me these results.
    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 WilliamsJon Williams Posts: 6,491
    edited 2005-10-18 20:39
    It looks like the Scratchpad got corrupted, and transfered that corrupt informat to the memory. Make sure your 1-Wire connections are stout; in my experience the DS1996 is very finicky with timing, so anything that could affect 1-Wire signalling may cause a problem.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.