CRC: bytewise vs. wordwise different results

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CRC: bytewise vs. wordwise different results

1,503 Views
xarowubas
Contributor III

Device: K60 (little-endian)

I program in assembly.

If I write 4 bytes representing the ASCII string "abcd" as a 32 bit *word* to CRC_CRC, I get a different checksum than when I write 4 single bytes in the order 'a', 'b', 'c', 'd' to CRC_CRC[LL], i.e., 4 separate STRB instructions.

Why?

results for wordwise calculation:

input: abcd
checksum: 0x79A5961D

input: dcba
checksum: 0x1D39469F

results for bytewise calculation:

input: abcd
checksum: 0x1D39469F

input: dcba
checksum: 0x79A5961D

Labels (1)
0 Kudos
Reply
2 Replies

1,285 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Xaro,

Don't know how you configure the CRC module.
Have you try to refer the crc example in SDK_2.2_TWR-K60D100M(C:\SDK_2.2_TWR-K60D100M\boards\twrk60d100m\driver_examples\crc)?

crc example.png
I can only get the result 0xED82CD11 by using online CRC calculation.

online CRC calculation.png

I can also get the same result from K60 running crc example in SDK_2.2_TWR-K60D100M.

crc example result.png

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,285 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

wordwise calculation

If you debug that example, you can see the value write into CRC_DATA is 0x64636261

32-bit reads and writes.png

bytewise calculation:

base->ACCESS8BIT.DATALL = *data;

input a(0x61)

input b(0x62)

input c(0x63)

input d(0x64)

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply