Skip to main content
EOCon
Visitor II
June 18, 2019
Question

STM32L0 CRC vs software

  • June 18, 2019
  • 1 reply
  • 900 views

Hi all,

I am generating a CRC using the hardware CRC module in my STM32L0 of which I fetch only the bottom byte.

I want corresponding C code to generate the same result as the hardware calculator, I have tried many different settings and Polynomials, bit reversal etc, but I cannot get a match between the two.

Here are my STM32L0 CRC settings:

hcrc.Instance = CRC;
	hcrc.Init.DefaultPolynomialUse = DEFAULT_POLYNOMIAL_DISABLE;
	hcrc.Init.DefaultInitValueUse = DEFAULT_INIT_VALUE_ENABLE;
	hcrc.Init.InputDataInversionMode = CRC_INPUTDATA_INVERSION_NONE;//CRC_INPUTDATA_INVERSION_BYTE;
	hcrc.Init.OutputDataInversionMode = CRC_OUTPUTDATA_INVERSION_DISABLE;//CRC_OUTPUTDATA_INVERSION_ENABLE;
	hcrc.Init.GeneratingPolynomial = 0x4C11DB7;
	hcrc.Init.CRCLength= CRC_POLYLENGTH_32B;
	hcrc.InputDataFormat = CRC_INPUTDATA_FORMAT_BYTES;
	__HAL_RCC_CRC_CLK_ENABLE();
	HAL_CRC_Init(&hcrc);
	__HAL_RCC_CRC_CLK_DISABLE();

and here is how I call the function to generate the CRC for me, flashbuff is a char buffer:

crc= HAL_CRC_Calculate(&hcrc,(uint32_t *) flashbuff, 12);

What C code can I use to generate the same value in the lower byte as the hardware internal generator using software?

Eoin

This topic has been closed for replies.

1 reply

Tesla DeLorean
Guru
June 21, 2019

Provide a test pattern, I take a look

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..