Skip to main content
Associate III
April 23, 2024
Solved

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

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.

 

This topic has been closed for replies.
AScha.3
AScha.3Best answer
Super User
April 23, 2024

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 on " Best Answer ".

4 replies

AScha.3
Super User
April 23, 2024

>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 on " Best Answer ".
WCareyAuthor
Associate III
April 23, 2024

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

WCareyAuthor
Associate III
April 23, 2024

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

AScha.3
AScha.3Best answer
Super User
April 23, 2024

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 on " Best Answer ".