Question
Big Endian CRC
Posted on November 12, 2013 at 22:51
I would like to use the hardware CRC on the STM32F407 with DMA.
However, my data comes in Big Endian, so if I just use the memory to memory DMA setup my CRC does not compute correctly. Is there a way that I can configure my DMA stream to perform a byteswap for me? Section 10.3.10 of the reference manual [Doc ID 018909 Rev 5] refers to unpacking and edian behavior of the DMA stream but I don't understand if any of that is pointing to swapping 4bytes in a memory to memory transfer. Alternately, if I have to use programmed IO, what is the fastest way to swap my bytes and send them off? The following does what I want, but I suspect there is a way to acheive the same thing with far fewer operations. for(int u=0; u<8; u++) { uint32_t temp =0; temp|= (readBuff[(u*4)]&0xFF)<<24; temp|= (readBuff[(u*4+1)]&0xFF )<< 16; temp|= (readBuff[(u*4+2)]&0xFF) << 8; temp|= (readBuff[(u*4+3)]&0xFF) << 0; CRC->DR=temp; } Thanks, Amaury #crc32 #dma #endian