Hi To All
i,m reading about crc on this thread http://www.picbasic.co.uk/forum/showthread.php?t=11790 and crc8 implementation for this code:This Works with the values stored previously in lookup, however this could be implemented in a similar way for Hserin or Hserout in runtime ?, searching in the forum mostly of the examples involves data previously stored on program i,m building a vending machine that process information about rs232 and the data is changing constantly my project involves a 16f1938 microcontroller, i aprreciatte any advice about this issue.Code:CRC VAR BYTECRC_IDX VAR BYTE CRC_IN VAR BYTE CRC_Poly CON $31 CRC8: FOR CRC_IDX = 0 to 7 IF (CRC.7 ^ CRC_IN.7) THEN CRC = (CRC << 1) ^ CRC_Poly ELSE CRC = CRC << 1 ENDIF CRC_IN = CRC_IN << 1 NEXT CRC_IDX RETURN X VAR BYTE CRC = 0 FOR X = 0 TO 8 LOOKUP X,[$AD, $42, $CB, $16, $05, $06, $00, $6C, $0E], CRC_IN HSEROUT [HEX2 CRC_IN," "] GOSUB CRC8 NEXT X HSEROUT ["= ",HEX2 CRC,13,10,13,10] CRC = 0 FOR X = 0 TO 8 LOOKUP X,[$AD, $42, $CC, $16, $05, $08, $00, $6C, $0C], CRC_IN HSEROUT [HEX2 CRC_IN," "] GOSUB CRC8 NEXT X HSEROUT ["= ",HEX2 CRC,13,10,13,10]
Best Regards
Brainless




Bookmarks