cancel
Showing results for 
Search instead for 
Did you mean: 

what does the polynomial become when crc8

RSolo.1
Associate II

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;
}

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

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".

View solution in original post

4 REPLIES 4
TDK
Guru

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
Associate II

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?

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
Associate II

thank you friend. this really helped