2023-10-22 07:18 PM - edited 2023-10-22 07:41 PM
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?
Solved! Go to Solution.
2023-10-22 07:42 PM
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.
2023-10-22 07:24 PM
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.
2023-10-22 07:35 PM
In the CubeMX I have already activated the CRC
and in stm21f0xx_hal_conf.h file the #define HAL_CRC_MODULE_ENABLED is already uncommented.
2023-10-22 07:42 PM
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.