This code was developed by Ken Webster for his Time Source Monitoring Test System
14-bit core PIC source:
PC Windows NT or 95 or 98 source to talk to PIC:
Uses CRC and checksum and packet serial number to detect corrupt or missing packets. Chop out code that supports channels if you only need one device connected (this app is for connecting multiple devices via a multiplexer). If need help feel free to email me at ken@webster.org
; Apply W to command-interpreter receive checksums
update_crx_checksums xor rCmdxs, W ;update plain checksum
xor rCmdcl, W ;update cyclic checksum
add rCmdch, W
clrb C
rr rCmdch
snb rCmdcl.0
setb rCmdch.7
rr rCmdcl
mov W, #$31
add rCmdcl, W
snb C
inc rCmdch
mov W, #$03
add rCmdch, W
void Checksum::Add(unsigned char c){ plain_checksum ^= c;
cyclic_checksum ^= c; cyclic_checksum += (unsigned short)c << 8;
bool carry = (cyclic_checksum & 1) ? true : false; cyclic_checksum >>= 1;
cyclic_checksum |= carry ? 0x8000 : 0; cyclic_checksum += 817;}