Author Topic: STM32 CRC Flash  (Read 4707 times)

0 Members and 1 Guest are viewing this topic.

Offline hamdi.tnTopic starter

  • Frequent Contributor
  • **
  • Posts: 623
  • Country: tn
STM32 CRC Flash
« on: January 21, 2016, 10:49:26 am »
Hi,

Am trying to add CRC32 in the end of the Flash memory of an STM32F101 using IAR tool. So far so good , IAR generate "a" CRC32 and write it in the end of memory.
I wrote a function that calculate CRC using integrated CRC hardware

Code: [Select]

#define MEM_START       0x08000000
#define MEM_END         0x0803FFF8
#define MEM_CRC         0x0803FFFC

uint32_t CheckFlashCRC()
{

CRC_ResetDR();
CRC_CalcBlockCRC((u32 *)MEM_START,((MEM_END-MEM_START)/4)+1);

return(*(u32 *)MEM_CRC));
}


The result of this routine is 0x784888AC
the IAR CRC is 0x60D8E753

and i couldn't make those two equal no matter what i change in IAR parameters , the previous values match the parameters in the picture.

Thanks

 

Offline hamdi.tnTopic starter

  • Frequent Contributor
  • **
  • Posts: 623
  • Country: tn
Re: STM32 CRC Flash
« Reply #1 on: January 21, 2016, 11:37:59 am »
 

Offline dgtl

  • Regular Contributor
  • *
  • Posts: 183
  • Country: ee
Re: STM32 CRC Flash
« Reply #2 on: January 21, 2016, 11:02:03 pm »
Alternatively, you can use the STM32's CRC unit to calculate the real ethernet crc32 with a little software workaround (they connected the bit order wrong). In some projects, the real crc32 calculation is needed too and then accelerating it is useful. See this c++ example here; with a little help you can de-obfuscate it back to C: https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fcortex_mx_stm32%2FSTM32F4%20CRC%20-%20Preload%20CRC-DR&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=2071#{295C81A5-7BF1-49F8-B25A-73D6FB23E2E1}
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf