Skip to main content
RSolo.1
Associate II
January 10, 2024
Solved

what does the polynomial become when crc8

  • January 10, 2024
  • 3 replies
  • 2713 views

Greetings. I ran into a problem, I can’t figure out how to become a polynomial if I use not 32 binary mode but in 8 bit mode. MCU STM32F072x8/xB
if I use a 32-bit setting, I get the correct data and can process it on a PC, but with 8 bits it doesn’t work..

 

 

uint32_t crc32(uint8_t *data, uint16_t size){
	uint32_t crc = 0;
	SET_BIT(CRC->CR, CRC_CR_RESET); // RESET bit
	for (int i = 0; i < size; i ++){
		CRC->DR = * (data + i);
	}
	crc = CRC->DR;
 return crc;
}

 

 

 

This topic has been closed for replies.
Best answer by TDK

There was a typo in my response. Try again.

How did you know that this is what you need to do?

Experience, but I'm sure it's also noted in the reference manual. You could also go off of what HAL_CRC_ functions do for this case.

https://github.com/STMicroelectronics/stm32f0xx_hal_driver/blob/0c66a5bd9c5a1ba51f40d26f2387b3ee44b495d2/Src/stm32f0xx_hal_crc.c#L455C7-L455C120

 

3 replies

TDK
Super User
January 10, 2024

You're using 32-bit access there. If you want to process 8 bits at a time, you need to use byte access:

 

*(volatile uint8_t *)&CRC->DR = value;

 

 

"If you feel a post has answered your question, please click ""Accept as Solution""."
RSolo.1
RSolo.1Author
Associate II
January 10, 2024

hm I did as you said but flew out
Infinite_Loop:
b Infinite_Loop
How did you know that this is what you need to do?

TDK
TDKBest answer
Super User
January 10, 2024

There was a typo in my response. Try again.

How did you know that this is what you need to do?

Experience, but I'm sure it's also noted in the reference manual. You could also go off of what HAL_CRC_ functions do for this case.

https://github.com/STMicroelectronics/stm32f0xx_hal_driver/blob/0c66a5bd9c5a1ba51f40d26f2387b3ee44b495d2/Src/stm32f0xx_hal_crc.c#L455C7-L455C120

 

"If you feel a post has answered your question, please click ""Accept as Solution""."
RSolo.1
RSolo.1Author
Associate II
January 10, 2024

thank you friend. this really helped