| ??? 01/14/02 23:04 Read: times |
#18662 - RE: CRC16 and HDLC |
Franc,
Try this routine: 1st prior to processing the string (or your single byte) init both crc_hi & crc_lo = 0FFH (not for each byte but just prior to the entire record to be handled). After the entire string has passed byte by byte through the routine. append crc_hi & crc_lo (complimented) ------------------- crc16: push ar0 push acc push psw ; *** Begin the CRC Routine *** mov r0,#8 xrl crc_hi,a crc_lp1: clr c mov a,crc_lo rrc a mov crc_lo,a mov a,crc_hi rrc a mov crc_hi,a jnc crc_lp2 xrl crc_hi,#08h xrl crc_lo,#84h crc_lp2: djnz r0,crc_lp1 pop psw pop acc pop ar0 ret --------------------- For instance: ---------------- mov crc_lo,#0FFH mov crc_hi,#0FFH mov a,#1 call crc16 ------------ at this point crc_hi=0EH crc_lo=1EH if we compliment it ("cpl a") we get *crc_hi=F1 *crc_lo=E1 Now lets do it with 2 ------------- mov crc_lo,#0FFH mov crc_hi,#0FFH mov a,#2 call crc16 ------------ at this point crc_hi=95H crc_lo=2CH if we compliment it we get *crc_hi= 6AH *crc_lo=D3H regards, p |
| Topic | Author | Date |
| CRC16 and HDLC | 01/01/70 00:00 | |
| RE: CRC16 and HDLC | 01/01/70 00:00 | |
| RE: CRC16 and HDLC | 01/01/70 00:00 | |
| RE: CRC16 and HDLC | 01/01/70 00:00 | |
| RE: CRC16 and HDLC | 01/01/70 00:00 | |
| RE: CRC16 and HDLC | 01/01/70 00:00 | |
| RE: CRC16 and HDLC | 01/01/70 00:00 | |
RE: CRC16 and HDLC | 01/01/70 00:00 |



