The Real MicroMan
New Member
Has anybody interfaced a PIC to an iButton. If so did you have to do the code in asm or C?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature currently requires accessing the site using the built-in Safari browser.
;******************************************************************
;
; Mike McLaren's Dallas one-wire 8-bit CRC code for the DS18B20
;
; clear the CRC variable then run each byte from the scratchpad
; read or ROM read operation through the CRC_Calc subroutine (a
; final CRC value of '0' indicates "good data").
;
; void CRC_Calc ()
; { crc ^= IOByte;
; for (i = 0; i < 8; i++)
; { if (crc & 0x01)
; crc = (crc >> 1) ^ 0x8C;
; else
; crc = crc >> 1
; }
; }
;
; entry: IOByte contains data byte
; exit: CRC contains cumulative CRC data
;
CRC_Calc
movlw d'8' ; |B0
movwf Count ; setup bit counter |B0
movf IOByte,W ; |B0
xorwf CRC,f ; |B0
movlw h'8C' ; x8+x5+x4+1 polynomial |B0
CRC_Next
clrc ; |B0
rrf CRC,f ; |B0
skpnc ; |B0
xorwf CRC,f ; toggle b7, b3, and b2 bits |B0
decfsz Count,f ; all done? yes, skip, else |B0
goto CRC_Next ; process the next IOByte bit |B0
return ; |B0
;