Hello, I’m facing some problems with the CRC HAL library when I want to change the polynomial to use. I want to use the 16 bits CRC/ARC polynomial (0x8005).
I try this to use this:
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
uint32_t CRCtest0 = 0;
uint32_t CRCtest1 = 0;
//uint32_t CRCtest2 = 0;
uint8_t txData[10]={0xF2, 0x10, 0x10, 0xE0, 0x3F, 0x35};
uint8_t crcdatatest1 [4] = {0xF2, 0x10, 0x10, 0xE0};
uint8_t crcdatatest2 [4] = {0xE0, 0x10, 0x10, 0xF2};
int main(void)
{
/* MCU Configuration----------------------------------------------------------*/
HAL_Init();
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_USART2_UART_Init();
MX_ADC1_Init();
MX_CAN1_Init();
MX_COMP1_Init();
MX_COMP2_Init();
MX_CRC_Init();
MX_UART4_Init();
MX_UART5_Init();
MX_SPI2_Init();
MX_I2C1_Init();
HAL_CRCEx_Polynomial_Set(&hcrc, 0x8005, CRC_POLYLENGTH_16B);
hcrc.Init.DefaultInitValueUse = 0;
hcrc.Init.InitValue = 0;
/* Infinite loop */
while (1)
{
CRCtest0 = HAL_CRC_Calculate(&hcrc, (uint32_t *)txData, 4);
CRCtest1 = HAL_CRC_Calculate(&hcrc, (uint32_t *)crcdatatest1, 4);
HAL_Delay(1000);
}
}
The returned values in CRCtest0 and CRCtest2 are both 0x8B0C which is not correct. According to CRC16/ARC polynomial the result should by 0x353F.
There is any other configuration that I’m missing?
Thanks,
Manel
