Here is the secret to get it working. I did some debugging with my Salae Logic debugging tool and watched the data coming back and forth - very cool debugging tool.
Here is the snippet of the code than handles the reading and writing of the values. In the write section I added 7 dummy bytes as the unit can only write an 8 byte minimum. I used 'bcd' for my dummy bytes as it is my company initials, but you could use h00.
<code>
' this is where we write the value to the one wire eeprom
' first off we write to the scratchpad
OWOUT DQ,1,[$CC,$0F,$00,$00,mode,$bc,$db,$cd,$bc,$db,$cd,$BC] ' write the mode data and 7 dummy bytes.
OWIN DQ,0,[OnewROM, oneWROM] ' read back the two CRC bytes (we don't care about them so they go into a generic bucket)
' then we read it back to get a memory access key
OWOUT DQ,1,[$CC,$AA] ' read back the memory code and data
OWIN DQ,0,[TA1,TA2,ES,OneWrom1,OneWrom2,OneWrom3,OneWrom4,One Wrom5,OneWrom6,OneWrom7,OneWrom8,OneWRom, OneWRom]
' debug "Returned Data:", hex2 TA1, hex2 TA2, hex2 ES, hex2 OneWrom1, hex2 OneWrom2, hex2 OneWrom3, hex2 OneWrom4, hex2 OneWrom5, hex2 OneWrom6, hex2 OneWrom7, hex2 OneWrom8, 10
' I added this so I could see in terminal what came back.
' then we write again using the key to put the data into memory
OWOUT DQ,1,[$CC,$55,TA1,TA2,ES] ' Commit the scratchpad to memory using the TA1 and 2 and ES value the EEPROM gave us
high dq
pause 20 ' wait for the data to be written
OWIN DQ,0,[OnewROM] ' this will return $AA if the data was sucessfully written
</code>
Hope this is useful to someone.
Attached is what part of the transaction looks like in the Logic data analyser app.
bill




Bookmarks