??? 04/08/04 15:00 Read: times |
#68192 - RE: CRC question Responding to: ???'s previous message |
hi,
No, we don't. If we change direction, we change the polynomial bit ordering too (e.g., 0x8408 represents the same polynomial when processing bytes least-significant bit first). Sure? Okay, then help me to find a error here: ;#define ROLL_L ;#define ROLL_R USING 0 ; START: ; CRC empty MOV R0,#0 MOV R1,#0 ; data array: 2 bytes of data + 2 bytes of their CRC MOV R2,#0x12 CALL CRC_CALC MOV R2,#0x34 CALL CRC_CALC MOV R2,#0x13 CALL CRC_CALC MOV R2,#0xC6 CALL CRC_CALC JMP $ #ifdef ROLL_L ; MSB rotation CRC-16 with 0x1021 ; C <- R1 <- R0 <- R2 CRC_CALC: MOV R7,#8 CRC_CYC: MOV A,R2 RLC A MOV R2,A MOV A,R0 RLC A MOV R0,A MOV A,R1 RLC A MOV R1,A JNC CRC_NEXT MOV A,#0x10 XRL AR1,A MOV A,#0x21 XRL AR0,A CRC_NEXT: DJNZ R7,CRC_CYC RET #endif #ifdef ROLL_R ; LSB rotation CRC-16 with 0x8408 ; R2 -> R1 -> R0 -> C CRC_CALC: MOV R7,#8 CRC_CYC: MOV A,R2 RRC A MOV R2,A MOV A,R1 RRC A MOV R1,A MOV A,R0 RRC A MOV R0,A JNC CRC_NEXT MOV A,#0x84 XRL AR1,A MOV A,#0x08 XRL AR0,A CRC_NEXT: DJNZ R7,CRC_CYC RET #endif END Just copy it to Keil, then un-comment either #define ROLL_L or #define ROLL_R, compile and and debug. With ROLL_L (MSB rotation) is produces zero-result, with ROLL_R (LSB rotation) it does not. In last case it requires: MOV R2,#0x86 ; was 0x13 CALL CRC_CALC MOV R2,#0xD1 ; was 0xC6 CALL CRC_CALC as two CRC bytes. Could you find a solution, please? Thanks, Oleg |
Topic | Author | Date |
CRC question | 01/01/70 00:00 | |
RE: CRC question | 01/01/70 00:00 | |
RE: CRC question | 01/01/70 00:00 | |
RE: CRC question | 01/01/70 00:00 | |
RE: Dallas CRC | 01/01/70 00:00 | |
RE: CRC question | 01/01/70 00:00 | |
RE: CRC question | 01/01/70 00:00 | |
RE: CRC question | 01/01/70 00:00 | |
RE: CRC question | 01/01/70 00:00 | |
RE: CRC question | 01/01/70 00:00 | |
RE: CRC question | 01/01/70 00:00 | |
RE: CRC question | 01/01/70 00:00 | |
RE: CRC question | 01/01/70 00:00 | |
RE: CRC question | 01/01/70 00:00 | |
RE: CRC question | 01/01/70 00:00 | |
RE: CRC question | 01/01/70 00:00 | |
RE: CRC question | 01/01/70 00:00 | |
RE: CRC question | 01/01/70 00:00 | |
RE: CRC question![]() | 01/01/70 00:00 |