Getting the HAL_CRC module to generate a CRC32
- January 5, 2022
- 1 reply
- 1915 views
I'm trying to get the HAL_CRC module to generate a 32bit CRC32 that matches the online calculators and matches what I get out of python with binascii.crc32() or zlib. I have a DoCkecksum() call below that calls HAL_CRC_Calculate() and I have called it with every combination of the input parameters but none of them match the calculated crc I get with the online calculators or with my python script. My python script does match the online calculators and for the value in the function the CRC should be 0x47A79BF9.
I'm running a project on an STM32H745 Nucleo board. I've also attached the project. All the relevant code is in main.c.
uint32_t DoChecksum(uint32_t inputFormat, uint32_t inputReverse, uint32_t outReverse)
{
uint32_t uiCRCCalc;
uint32_t uiVal;
uiVal= 0xC0DE50FF;
hcrc.Init.DefaultPolynomialUse = DEFAULT_POLYNOMIAL_ENABLE;
hcrc.Init.DefaultInitValueUse = DEFAULT_INIT_VALUE_ENABLE;
hcrc.Init.InputDataInversionMode = inputReverse;
hcrc.Init.OutputDataInversionMode = outReverse;
hcrc.Init.CRCLength= CRC_POLYLENGTH_32B;
hcrc.InputDataFormat = inputFormat;
HAL_CRC_DeInit(&hcrc);
HAL_CRC_Init(&hcrc);
uiCRCCalc = HAL_CRC_Calculate(&hcrc, &uiVal, 1);
return(uiCRCCalc);
}
