2018-05-10 12:28 AM
STM32L452C
My code:
__HAL_RCC_CRC_CLK_ENABLE();
CRC->POL = (uint32_t) 0x1021;//CRC-16-CCITT CRC->INIT = (uint32_t) 0xFFFF; CRC->CR = (uint32_t) 0x09;//REV_OUT = 0, REV_IN = 00, POLYSIZE = 01, RESET = 1 CRC->DR = '1'; CRC->DR = '2'; CRC->DR = '3'; CRC->DR = '4';The correct result for this CRC is 0x5349 but when I read the DR I get 0xb23b
I have tried all combinations of input and output bit reversal, doesn't work.
2018-05-10 1:18 AM
Hi
robert.015
,I recommend you to have a look to CRC examples under the STM32L4 firmware package, it may helpful to start your own project:STM32Cube_FW_L4_V1.0\Projects\NUCLEO-L452RE\Examples\CRC
-Nesrine-
2018-05-10 3:59 AM
Thanks. I just realised that the cubeMX utility doesn't copy all the HAL drivers to your project dir. I was missing 'stm32l4xx_hal_crc.c' etc.
2018-05-16 8:55 AM
DR is a 32-bit wide register, you need to write bytes 8-bit wide, thusly...
*((volatile uint8_t *)&CRC->DR) = '1';
2018-05-16 10:48 AM
Could you please precise the MX version are you using?
if your are using an older version please use the latest one and tell us if the issue still again
We’re moving the ST Community to a new platform to give you a better and more reliable community experience.