Hi Henrik,
here is the snippit I am testing:
Code:
Main: 'DO WHATEVER YOU WANT HERE
tmr1=0
t1con = 1
For MB_j = 0 to 7 ' Cycle thru the low byte of the CRC value
If MB_CRC.Bit0 THEN ' If the LSB is set
MB_CRC = MB_CRC >> 1 ' We shift CRC on bit to the right....
MB_CRC = $A001 ^ MB_CRC ' and EXOR it with out polynomial for MODBUS CRC-16 ($A001)
ELSE
MB_CRC = MB_CRC >> 1 ' If the LSB is not set we simply shift CRC one bit to the right.
ENDIF
Next ' Next bit in the byte
t1con = 0
stopnow:
goto stopnow
This takes 169 cycles according to TMR1 setup as you see here. I have tried with both $A001 and $1021. Both are the same. Does this fall in line with what you have?
BTW, MPLAB stopwatch reports the same
Next I think I will try out DT's snippet
Bookmarks