Calculate/check USB crc16
Posted: Wed Jul 12, 2017 4:00 pm
Hello,
I am trying to create assembler code to calculate USB crc16.
My problem is that I don't understand how to properly call assembler crc8 instructions in chain.
My try:
ldc r7, 0x8408 // polynomial x16+x12+x5+x0 bit reversed
ldc r3, 0xffff // initial value
ldc r5, 0
crc8 r3, r4, r3, r7 // ???
zhcrc16_loop1:
bf r1, zhcrc16_loop2 // loop
ld8u r3, r0[r5] // take the next byte
add r0, r0, 1 // increment pointer
crc8 r3, r4, r3, r7 // ???
sub r1, r1, 1 // decrement length
bu zhcrc16_loop1 // loop again
zhcrc16_loop2:
ldc r0, 0xffff
and r0, r3, r0 // result crc16 value in r0
Thanks for looking into it.
I am trying to create assembler code to calculate USB crc16.
My problem is that I don't understand how to properly call assembler crc8 instructions in chain.
My try:
ldc r7, 0x8408 // polynomial x16+x12+x5+x0 bit reversed
ldc r3, 0xffff // initial value
ldc r5, 0
crc8 r3, r4, r3, r7 // ???
zhcrc16_loop1:
bf r1, zhcrc16_loop2 // loop
ld8u r3, r0[r5] // take the next byte
add r0, r0, 1 // increment pointer
crc8 r3, r4, r3, r7 // ???
sub r1, r1, 1 // decrement length
bu zhcrc16_loop1 // loop again
zhcrc16_loop2:
ldc r0, 0xffff
and r0, r3, r0 // result crc16 value in r0
Thanks for looking into it.