Skip to main content
sbend
Associate II
April 9, 2025
Solved

Using Zephyr, enabling and using STM32F412 CRC peripheral

  • April 9, 2025
  • 2 replies
  • 710 views

Hi,

I am trying to initialize and use the internal CRC peripheral in the STM32F412 MCU. My application is based on Zephyr RTOS, using the STM32 HAL.

My application defines the CONFIG_USE_STM32_HAL_CRC, so the stm32f4xx_hal_crc.c is included in the build.

The application builds and links just fine, and I can call the HAL_CRC_Init, HAL_CRC_GetState and HAL_CRC_Calculate without any problems.

Only problem is the calculation is 0 for my 4 test bytes (0x01, 0x02, 0x03, 0x04).

 

Debugging through the code, it does set the "hcrc->Instance->DR" in stm32f4xx_hal_crc.c

Are there any additional settings I need to include? Maybe clock configurations?

Best answer by Tesla DeLorean

If registers be zero, check you've enabled the peripheral clock before use, either in main.c or your stm32f4xx_hal_msp.c

/* CRC Peripheral clock enable */

__HAL_RCC_CRC_CLK_ENABLE();

2 replies

Tesla DeLorean
Guru
April 9, 2025

If registers be zero, check you've enabled the peripheral clock before use, either in main.c or your stm32f4xx_hal_msp.c

/* CRC Peripheral clock enable */

__HAL_RCC_CRC_CLK_ENABLE();

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
sbend
sbendAuthor
Associate II
April 10, 2025

Thank you! That solved the issue.