;******************************************************************
;
; 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 BitCtr ; setup bit counter |B0
movf owByte,W ; |B0
xorwf CRC,F ; |B0
movlw h'8C' ; W = 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 BitCtr,F ; all done? yes, skip, else |B0
goto CRC_Next ; process the next IOByte bit |B0
return ; |B0
;