2019-06-13 06:00 AM
I am working on STM32L151QD MCU. I want to implement CRC feature in my application using STM hardware CRC block.
i am trying below steps to configure HW CRC:
uint32_t crc;
uint32_t t_buffer[4] = {1,2,3,4};
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_CRC, ENABLE);
//Reset HW CRC
CRC_ResetDR();
crc = CRC_CalcBlockCRC(t_buffer, sizeof(t_buffer));
printf("hw crc = %d\n", crc);
if ( CRC_GetCRC() != crc)
{
printf("error in HW CRC\n");
}
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_CRC, DISABLE); /* Turn OFF CRC */
return crc;
But every time HW computed CRC is different even if the input buffer is same all the time.
am i missing anything?
anything else to be configured to get correct CRC ?
2019-06-13 06:17 AM
Isn't the length parameter a word count, not a byte count?
2019-06-13 06:40 AM
Hi there was a mistake. in code i am passing word count only. and i was debugging the code. i understood why i was getting different CRC everytime.
I have to reset DR register - CRC_ResetDR() during start of every computation.
Thanks