cancel
Showing results for 
Search instead for 
Did you mean: 

stm32f103re CRC ?

kshin.111
Associate III

 

hi 

i used of CRC in stm32CubeMX and for check true worked CRC used of two online CRC calculator site:

https://www.sunshine2k.de/coding/javascript/crc/crc_js.html

&

https://crccalc.com/?crc=123456789&method=&datatype=0&outtype=0

 

i think stm32cubeIDE internal CRC use of standard CRC32_MPEG2:

Polynomial = 0x4C11DB7

Initial value = 0xFFFFFFFF

Final XoR Value = 0x0

Input reflected = disable

Result reflected = disable

Am I correct and have I written the CRC parameter values ​​for stm32f103 exactly right?

...........

but CRC result for stm32CubeIDE different with online CRC calculator site?

example:

stm32 CRC for 0x00 = 0xc704dd7b

online CRC calculator site for 0x00 = 0x4E08BFB4

 

stm32 CRC for 0x01 = 0xc3c5c0cc

online CRC calculator site for 0x01 = 0x4AC9A203

 

stm32 CRC for 0x02 = 0xce86e615

online CRC calculator site for 0x02 = 0x478A84DA

 

stm32 CRC for 0xFF = 0x76f39dcf

online CRC calculator site for 0xFF = 0xFFFFFF00

 

............ my Code:

 

 

 

#include "main.h" void SystemClock_Config(void); int main(void) { extern CRC_HandleTypeDef hcrc; //CRC uint32_t buff[2]; uint32_t result = 0xffffffff; uint32_t i = 0; // HAL_Init(); SystemClock_Config(); MX_GPIO_Init(); MX_USART1_UART_Init(); MX_I2C1_Init(); MX_SPI1_Init(); MX_CRC_Init(); while (1) { i = 0; while(i < 256) { buff[0] = i; result = HAL_CRC_Calculate(&hcrc, &buff[0], 1); i++; } } }

 

 

 

 

-------------------------

please help me

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
waclawek.jan
Super User

The CRC unit in 'F1 calculates CRC only from 32-bit words, so for example for your 0x01 input it uses 0x00000001 (big endian, so 0x00 0x00 0x00 0x01):

waclawekjan_0-1728026802482.png

 

JW

View solution in original post

6 REPLIES 6
PGump.1
Senior III

Hi,

Are you using the polynomial reversed, or the reciprocal?

Kind regards
Pedro

AI = Artificial Intelligence, NI = No Intelligence, RI = Real Intelligence.

stm32cubeIDE CRC for STM32F103RE is constant value and can not change any CRC parameter.

and i used for one Byte value.

0

1

2

0xFF

 

I don't make any changes to the data.

I have read various CRC documents from st company and nowhere I have seen the value of CRC parameters used for STM32F103 so I don't know if it uses Reverse or Reciprocal or not.

 

Hi,

The CRC unit needs to be Reset between each set of calculations. If HAL doesn't have a reset function, then try something like -

    CRC->CR |= CRC_CR_RESET;

before i = 0;

I hope this helps.

Kind regards
Pedro

AI = Artificial Intelligence, NI = No Intelligence, RI = Real Intelligence.
waclawek.jan
Super User

The CRC unit in 'F1 calculates CRC only from 32-bit words, so for example for your 0x01 input it uses 0x00000001 (big endian, so 0x00 0x00 0x00 0x01):

waclawekjan_0-1728026802482.png

 

JW

HAL automatic reset for function "HAL_CRC_Calculate()"

thanks thanks thanks