' -----[ Title ]----------------------------------------------------------- ' ' File...... 1WIRE-ID.BSP ' Purpose... Reads ROM data from 1-Wire device ' Author.... Jon Williams ' E-mail.... jonwms@aol.com ' {$STAMP BS2p} ' -----[ Program Description ]--------------------------------------------- ' ' Reads 1-Wire device ROM pattern. ' -----[ Constants ]------------------------------------------------------- ' OWpin CON 15 ' 1-wire device pin ' 1-Wire Support ' OW_FERst CON %0001 ' Front-End Reset OW_BERst CON %0010 ' Back-End Reset OW_BitMode CON %0100 OW_HighSpd CON %1000 ReadROM CON $33 ' read ID, serial num, CRC ' -----[ Variables ]------------------------------------------------------- ' idx VAR Byte ' loop counter romData VAR Byte(8) ' ROM data from DS1820 ' -----[ Main Code ]------------------------------------------------------- ' Main: OWOUT OWpin,OW_FERst,[ReadROM] ' send Read ROM command OWIN OWpin,OW_BERst,[STR romData\8] ' read serial number & CRC DEBUG CLS,"1-Wire ID: " FOR idx = 0 TO 7 DEBUG HEX2 romData(idx) ' show ID, serial num, CRC NEXT END