cancel
Showing results for 
Search instead for 
Did you mean: 

CRC peripheral can't get correct data

HarryQiu
Associate II

Hi there,

I currently use STM32L073 for evaluation and found some issue with CRC module.

L073 has a CRC peripheral whose polynomial is programmable. And when I programm the peripheral as below, the checksum returns from the module doesn't match the one from a 3-party calculator -- it has an extra XOR with 0xFF.

The peripheral configuration is as below. In this case, both the 3-party calculator and my software code get a result of 0x5A but the CRC peripheral in the L073 gives a result of 0xA5 (which is 0x5A XOR 0xFF). Same happens for other data input.

CRC->CR = 0x01;     //  reset CRC module
CRC->CR = 0x10;     //  8-bit polynomial
CRC->POL = 0xFE;    //  set polynomial
CRC->INIT = 0xFF;   //  set initial value
*(__IO unsigned char *)(CRC_BASE) = 0x5A;   //  8-bit write to CRC->DR register
result = CRC->DR;   //  readout CRC checksum

Could anyone please help me with this?

Thanks a lot.

Regards,

Harry

This discussion is locked. Please start a new topic to ask your question.
4 REPLIES 4
waclawek.jan
Super User

What's that 3rd party calculator? If it performs the final xor, well then you have to perform it too.

JW

Hi JW,

Thanks for your reply.

It's here: http://www.zorc.breitbandkatze.de/crc.html

It does have a "final XOR" configuration but unfortunately I put a "0" there. See below:

0693W00000BcmXXQAZ.pngI did some further investigation and seems if the LSB of the polynomial is "0" (in this case 0xFE = 8b11111110), the L073's CRC adds a final XOR with 0xFF to the result.

waclawek.jan
Super User

From the CRC chapter in RM:

Polynomial programmability

The polynomial coefficients are fully programmable through the CRC_POL register, and the 

polynomial size can be configured to be 7, 8, 16 or 32 bits by programming the 

POLYSIZE[1:0] bits in the CRC_CR register. Even polynomials are not supported.

JW

Ah I see. Thanks a lot. I missed that "Even..." part.