cancel
Showing results for 
Search instead for 
Did you mean: 

How to swap the SPI CRC value and then transmit it?

WCarey
Associate III

I enabled the SPI CRC calculation (with a length SPI_CRC_LENGTH_16BIT) in my STM32H563ZI  master application. During Tx, I want the 2 bytes of the calculated CRC to be swapped and transmitted i.e. a CRC of 0xABCD must be sent out as 0xCD 0xAB and not as 0xAB 0xCD.

Can someone let me know how to do this? 

Thanks.

 

1 ACCEPTED SOLUTION

Accepted Solutions

Well, i never used it, so i am just guessing:

- if you use the spi-auto-generated crc, you cannot "swap" this. It expects an STM32 with same crc unit as target.

- if you calculate the crc yourself , maybe with the crc unit or just in software, swap bytes, and put it as last value to the send-array , then send all; this should work, if you calculate crc exact in the way, the target expects.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

4 REPLIES 4
AScha.3
Chief II

>CRC of 0xABCD must be sent out as 0xCD 0xAB and not as 0xAB 0xCD.

Why this ? 

If you feel a post has answered your question, please click "Accept as Solution".

My slave application running on a different target receives the CRC in that order ( lower byte first ).

WCarey
Associate III

Can this be done using CRC peripheral itself rather than using SPI's CRC feature?

Well, i never used it, so i am just guessing:

- if you use the spi-auto-generated crc, you cannot "swap" this. It expects an STM32 with same crc unit as target.

- if you calculate the crc yourself , maybe with the crc unit or just in software, swap bytes, and put it as last value to the send-array , then send all; this should work, if you calculate crc exact in the way, the target expects.

If you feel a post has answered your question, please click "Accept as Solution".