Skip to main content
Visitor II
January 20, 2024
Question

Why my crc is not configurable ?

  • January 20, 2024
  • 2 replies
  • 1079 views

I tried to use the hardware crc for my device stm32f103  . But the STM32CubeMX ( version : 6.10 ) doesnot provide any parameters configuration for this IP. The generated  crc.c is as follows :


/* CRC init function */
void MX_CRC_Init(void)
{

/* USER CODE BEGIN CRC_Init 0 */

/* USER CODE END CRC_Init 0 */

/* USER CODE BEGIN CRC_Init 1 */

/* USER CODE END CRC_Init 1 */
hcrc.Instance = CRC;
if (HAL_CRC_Init(&hcrc) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN CRC_Init 2 */

/* USER CODE END CRC_Init 2 */

}

 

Is it possible to config the crc ? I would like to use the crc16 func. for MODBUS communication. Thanks !

2 replies

STOne-32
Technical Moderator
January 20, 2024

Hi @hanguofu ,

 

this is normal behavior and expected, CRC of First STM32F1 series is fixed to Ethernet Polynomial : have a look to our Reference Manual RM0008 . To have a configurable CRC you can select STM32F3 or STM32F0 or others series or to use Software function .

 

Cheers,

STOne-32

Tesla DeLorean
Guru
January 20, 2024

The MODBUS CRC can be done in software quite efficiently.

Posted multiple examples to the forum.

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