Messages older than 24 hours are automatically pruned from ChatBox.
Time User Message
New 21-01, 12:33
Need help interfacing a 16F1939 with a CrystalFontz CFA635 logic level serial display.Hi,
I'm trying to interface to a CrystalFontz CFA634, but I can't get code to work that will generate the correct CRC. One sample of their test code is used to clear the LCD. When I transmit that code with the CRC they suggest, it works.

'The string below sucessfully clears the LCD. The first three hex characters are the command, data length, and CR, and the last two are the CRC bytes:
HSEROUT [$06, $00, $97, $5B, $0D]

The code I'm trying to use was orginally contributed on this board:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Poly con $8408 ' CRC polynomial
I VAR BYTE
pData VAR BYTE
X VAR BYTE
CRC VAR WORD
C_Data VAR WORD
VAL VAR BYTE[3] ' Holds 3 values passed to CRC routiine
'
VAL[0] = $06
VAL[1] = $00
VAL[2] = $97
'
Begin:
CRC = $0000
for X = 0 TO 2
pData = VAL[X]
gosub Calc_CRC
next X
CRC = ~CRC
hserout [IHEX CRC.LowByte,IHEX CRC.HighByte,13,10]
pause 1000
goto Begin
'
Calc_CRC:
C_Data = $00FF & pData
CRC = CRC ^ C_Data
for I = 0 to 7
if CRC.Bit0 = 1 then
CRC = (CRC >> 1) ^ Poly
else
CRC = CRC >> 1
endif
next I
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

It returns a CRC code, but it doesn't match 0x5B, 0x0D

Any suggestions would be very greatly appreciated. The data sheet which contains the sample algorithms is at https://www.crystalfontz.com/product...2017-11-13.pdf