Skip to main content
Associate II
October 23, 2023
Solved

CRC_POLYLENGTH_16B undeclared in STM32F030CCTx

In `STM32F030CCTx` I need to set the CRC in 16-bit length by calling

 

HAL_CRCEx_Polynomial_Set(MATRIX_UART_settings->crc, CRC_POLY, CRC_POLYLENGTH_16B);

 

but the compiler shows the error :

 

'CRC_POLYLENGTH_16B' undeclared (first use in this function)

 

in the `stm32f0xx_hal_crc.h` file `CRC_POLYLENGTH_16B` is defined under preprocessor directive like

 

#if defined(CRC_POL_POL)
/** @defgroup CRC_Polynomial_Sizes Polynomial sizes to configure the peripheral
* @{
*/
#define CRC_POLYLENGTH_32B 0x00000000U /*!< Resort to a 32-bit long generating polynomial */
#define CRC_POLYLENGTH_16B CRC_CR_POLYSIZE_0 /*!< Resort to a 16-bit long generating polynomial */
#define CRC_POLYLENGTH_8B CRC_CR_POLYSIZE_1 /*!< Resort to a 8-bit long generating polynomial */
#define CRC_POLYLENGTH_7B CRC_CR_POLYSIZE /*!< Resort to a 7-bit long generating polynomial */
/**
* @}
*/

/** @defgroup CRC_Polynomial_Size_Definitions CRC polynomial possible sizes actual definitions
* @{
*/
#define HAL_CRC_LENGTH_32B 32U /*!< 32-bit long CRC */
#define HAL_CRC_LENGTH_16B 16U /*!< 16-bit long CRC */
#define HAL_CRC_LENGTH_8B 8U /*!< 8-bit long CRC */
#define HAL_CRC_LENGTH_7B 7U /*!< 7-bit long CRC */
/**
* @}
*/
#endif /* CRC_POL_POL */

 

How can I access the `CRC_POLYLENGTH_16B`? and any documentation for using the HAL CRC library?

This topic has been closed for replies.
Tesla DeLorean
Tesla DeLoreanBest answer
Guru
October 23, 2023

The STM32F030CC does not support the programmable polynomial modes, it just supports the default 32-bit method.

The RM defines how the hardware functions, the HAL here is a relatively thin abstraction.

For 16-bit CRC you're going to need to use software methods.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..

3 replies

TDK
October 23, 2023

In your CubeMX project, activate CRC under the Computing tab. This will set the defines appropriately such that the crc headers are included.

Alternatively, modify stm32f0xx_hal_conf.h and uncomment #define HAL_CRC_MODULE_ENABLED. This will do the same thing provided you already have the appropriate HAL CRC files in your project.

"If you feel a post has answered your question, please click ""Accept as Solution""."
SoadAuthor
Associate II
October 23, 2023

In the CubeMX I have already activated the CRC スクリーンショット 2023-10-23 113347.jpg

and in stm21f0xx_hal_conf.h  file the  #define HAL_CRC_MODULE_ENABLED is already uncommented.

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
October 23, 2023

The STM32F030CC does not support the programmable polynomial modes, it just supports the default 32-bit method.

The RM defines how the hardware functions, the HAL here is a relatively thin abstraction.

For 16-bit CRC you're going to need to use software methods.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..