cancel
Showing results for 
Search instead for 
Did you mean: 

How to reset Tx CRC calculator properly?

AFerr.1
Associate II

My application uses a STM8AF5288 as SPI slave with hardware Rx and Tx CRC calculator enabled.

Despite the information available on the Ref Manuals, just writing '1' to CRCEN bit of SPI_CR2 seems to work only on SPI_RXCRCR.

SPI_TXCRCR will not reset with this IF CRCEN WAS ALREADY SET.

My workarround was to modify the "SPI_ResetCRC()" function in std lib file "stm8s_spi.c" as follows:

void SPI_ResetCRC(void)

{

 /* Rx CRCR & Tx CRCR registers are reset when CRCEN (hardware calculation)

 bit in SPI_CR2 is written to 1 (enable) */

 SPI_CalculateCRCCmd(DISABLE); // by Ferro 2019-12-16

 SPI_CalculateCRCCmd(ENABLE);

 /* Previous function disable the SPI */

 SPI_Cmd(ENABLE);

}

 Looks like TXCRC resets with the rising edge...

Has anyone gone though this issue?

My app is working fine this way, but I'm unconfortable with assuming the std lib has such an error. Where did I go wrong? (if I did).

Thanks a lot in advance.

0 REPLIES 0