PDA

View Full Version : iButton



menze
- 26th June 2006, 00:37
Hello. I want to make a simple program that can write some code to a ibutton, then read it again, and then, store it in EEPROM, so I can check that the code has been programed ok. I have already spent a lot of time trying to make it work, but it doesnt. My ibutton is DS1993. Here is the code:

-------------------------------------------------


DEVICE 16F628
SYMBOL DQ = PORTB.2
DIM B1 AS BYTE
DIM HighAddress AS BYTE
DIM LowAddress AS BYTE
DIM EndAddress AS BYTE
DIM ReadIN[32] AS BYTE
B1 = $23
HighAddress = $00
LowAddress = $00
EndAddress = $0F

HIGH PORTA.4
DELAYMS 500
LOW PORTA.4
DELAYMS 1000
OWRITE DQ, 1, [$CC] ' Send Reset & Skip ROM command
OWRITE DQ, 0, [$0F] ' Send Write scratchpad command
OWRITE DQ, 0, [HighAddress] ' Send Start address. i.e.(14h)
OWRITE DQ, 0, [LowAddress] ' Send Start address. i.e.(00h), address=0014h

OWRITE DQ, 0, [B1,B1,B1,B1,B1,B1,B1,B1] ' Send No reset, 1st 8 bytes
OWRITE DQ, 0, [B1,B1,B1,B1,B1,B1,B1,B1] ' Send No reset, 2nd 8 bytes
OWRITE DQ, 0, [B1,B1,B1,B1,B1,B1,B1,B1] ' Send No reset, 3rd 8 bytes
OWRITE DQ, 2, [B1,B1,B1,B1,B1,B1,B1,B1] ' Send 4th 8 bytes & Reset


' Copy Data from scratchpad to page
OWRITE DQ, 1, [$CC] ' Send Reset & Skip ROM command
OWRITE DQ, 0, [$55] ' Send copy scratchpad command
OWRITE DQ, 0, [HighAddress] ' Send Start address. i.e.(14h)
OWRITE DQ, 0, [LowAddress] ' Send Start address. i.e.(00h), address=0014h
OWRITE DQ, 2, [EndAddress] ' Send E/S. (Last address written to) & Reset

OWRITE DQ, 1, [$CC] ' Send Reset & Skip ROM command
OWRITE DQ, 0, [$F0] ' Send Read memory command


OWRITE DQ, 0, [HighAddress] ' Send Start address. i.e.(14h)
OWRITE DQ, 0, [LowAddress] ' Send Start address. i.e.(00h), address=0014h
OREAD DQ, 2, [ STR ReadIN\32 ] ' Read 1st 32 Bytes & Reset
EWRITE 0, [READIN[0], READIN[1], READIN[2], READIN[3], READIN[4], READIN[5], READIN[6], READIN[7], READIN[8], READIN[9], READIN[10], READIN[11], READIN[12], READIN[13], READIN[14], READIN[15]]

HIGH PORTA.4
END

-------------------------------------------------


Thanks.

Melanie
- 26th June 2006, 01:36
Big thread on DS1994 iButton here...

http://www.picbasic.co.uk/forum/showthread.php?t=250

It's possible some code may be useful to you...

mister_e
- 26th June 2006, 05:00
but unfortunately, it's not going to be a pure copy/paste solution, you'll have to do some code modification to make it work with the compiler you use

menze
- 26th June 2006, 21:24
but unfortunately, it's not going to be a pure copy/paste solution, you'll have to do some code modification to make it work with the compiler you use


Thanks for all the info. I have no idea how to modiy the code because that code is used to read an ibutton cloik, but i need to read and write all the pages.
If you have some info, please send it to me.
Thanks again
Menze

mister_e
- 26th June 2006, 23:15
well i can't really tell you how about because i no longer use the PROTON compiler as i feel you use just by seeing your variable declaration, the way you write to EEPROM and the DelayMS statement.

maybe the PROTON forum will be handy for you
www.picbasic.org/forum

menze
- 26th June 2006, 23:48
well i can't really tell you how about because i no longer use the PROTON compiler as i feel you use just by seeing your variable declaration, the way you write to EEPROM and the DelayMS statement.

maybe the PROTON forum will be handy for you
www.picbasic.org/forum

Thanks for the info!!!
Menze