2024-01-10 06:27 AM - edited 2024-01-10 06:28 AM
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;
}
Solved! Go to Solution.
2024-01-10 06:47 AM - edited 2024-01-10 06:48 AM
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.
2024-01-10 06:35 AM - edited 2024-01-10 06:47 AM
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;
2024-01-10 06:42 AM
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?
2024-01-10 06:47 AM - edited 2024-01-10 06:48 AM
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.
2024-01-10 07:17 AM
thank you friend. this really helped