cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L1xxx Hardware CRC calculation

Rekha.k
Associate II

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 ?

2 REPLIES 2

Isn't the length parameter a word count, not a byte count?

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

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