2009-11-18 03:04 AM
CRC calculation unit gives bit reversed result
2011-05-17 03:41 AM
I'm using the CRC calculation unit and it seems that the result of the data register (CRC_DR) is bit-reversed and bit-wise inverted.
Entering 0x00000000 gives 0xC704DD7B as result which should be 0x2144DF1C (using srec). See also: http://zorc.breitbandkatze.de/crc.html http://www.lammertbies.nl/comm/info/crc-calculation.html?crc=00000000&method=hex Can anyone (from ST) confirm this? And what is the reason for this behaviour?2011-05-17 03:41 AM
Addition:
The reset value of the CRC_DR is 0xFFFFFFFF and not 0x00000000 as mentioned in the Reference Manual (RM0008 Rev 5).2011-05-17 03:41 AM
Hi Eric,
One correction : the reset value is 0x00000000 as described in the RM0008. You can check it easily after reset. The CRC clock is disabled by default so all the digital parts and registers are 0. However, once enabled it initializes to 0xFFFFFFFF. Cheers, STOne-32.2011-05-17 03:41 AM
Hi STOne-32,
You are right about the reset value. I'd make a mistake about reading the value after enabling the CRC clock. What abbout the first CRC issue? Thanks, Eric.2011-05-17 03:41 AM
Did you get anywhere on this? I'm also trying to use the hw CRC calculation unit and I'm getting the same results as you and not the results I'm expecting.
2011-05-17 03:41 AM
Hi,
Here is attached an equivalent algorithm to the embedded one and is written in C that you can use :) to check the results ... Enjoy it { just change .txt to .c } Cheers, STOne-32. [ This message was edited by: STOne-32 on 19-01-2009 17:16 ]2011-05-17 03:41 AM
Here is a code snippet to do the job:
static u32 rbit(u32 d) { __asm__ ( '' rbit %0, %0'' : ''=r'' (d) : ''0'' (d) : ''cc'' ); return d; } void foo(void) u32 *p, crc32; p = ...; Crc.CR.bit.RESET = 1; while ( ... ) { Crc.DR = rbit(*pd++); } crc32 = rbit(Crc.DR) ^ 0xFFFFFFFF; } The toolchain I used was CoudeSourcery. It doesn't have an intrisic function to do the bitreverse, So I made an inline function who use the Thumb-2 instruction 'rbit'.2011-05-17 03:41 AM
I seem to have different results with a stm32f107 chip. I was expecting what Eric got (0xC704DD7B) but instead the chip returned 0x552d22c8.
void foo(void) { CRC->CR = CRC_RESET; /* CRC->DR is now 0xffffffff */ CRC->DR = 0x00000000; /* CRC->DR is now 0x552d22c8 */ } Can anyone tell me if i overlooked something?2011-05-17 03:41 AM
Try reading my post on the subject.