cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4DISCOVERY CRC ISSUE

theflemme
Associate
Posted on May 25, 2015 at 14:57

Hi,

I'm working on the stm32f4discovery board, with the last version of keil µvision. I used library from stm32Cube. I have problem with CRC peripheral : I can't get a right result. My initialize code, before my infinite loop :

hcrc.Instance = CRC;
HAL_CRC_Init(&hcrc);
__HAL_RCC_CRC_CLK_ENABLE();

When i use CRC :

uint8_t data[64];
/*for test only*/
data[0]=0x1a;
data[1]=0x03;
data[2]=0x31;
data[3]=0x32;
data[4]=0x33;
__HAL_CRC_DR_RESET(&hcrc);
CRCvalue = HAL_CRC_Calculate(&hcrc, (uint32_t*) data, 5);

When I execute this code, i'm waiting CRCvalue = 89CE6D10 (value calculate by crc online tools, and i have the same result on my computer with my own program) but the value of my calculate CRC is :CRCvalue = 909801CA What am I doing wrong ? Thanks for your help,
2 REPLIES 2
Posted on May 25, 2015 at 16:10

What am I doing wrong ?

Probably by a) assuming the online calculators model the STM32 hardware, b) not understanding the capabilities of the STM32F4 CRC hardware.

The STM32F4 CRC is 32-bit wide, operates on 32-bit values (not 8-bit ones), and have an endian/shift that are not really compatible with each other.

I've covered this before here several times..

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on May 25, 2015 at 18:34

[DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/CRC%20computation&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=6562]https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fcortex_mx_stm32%2FCRC%20computation&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=6562

https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/How%20can%20I%20calculate%20the%20CRC%20in%20java&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F&current...

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