cancel
Showing results for 
Search instead for 
Did you mean: 

Slave SPI Error

Steven Keeter
Associate III
Posted on December 15, 2017 at 18:47

If a slave spi port is setup for interrupt with data size set to 16 bits, how do you recovery from error when an extra byte comes in?

HAL_SPI_GetError(&hspi1) returns 0x3 when read from error callback.  Solution anyone?  Runs fine if the received packet is always two bytes. 

1 ACCEPTED SOLUTION

Accepted Solutions
Steven Keeter
Associate III
Posted on December 18, 2017 at 14:25

Turned out that I had the NSS pin setup as software controlled instead of hardware input defined.  This condition caused the sync issue.

View solution in original post

2 REPLIES 2
Posted on December 18, 2017 at 00:08

I don't think there should be any error in this case except overrun SPI_SR.OVR (if you don't read SPI_DR until the next data arrive).

You didn't tell us any details, namely how exactly do you set up your SPI, and which STM32 you use, so I assumed STM32F4xx. But then it's strange as

#define HAL_SPI_ERROR_NONE          0x00000000U   /*!< No error         */

#define HAL_SPI_ERROR_MODF          0x00000001U   /*!< MODF error       */

#define HAL_SPI_ERROR_CRC           0x00000002U   /*!< CRC error        */

#define HAL_SPI_ERROR_OVR           0x00000004U   /*!< OVR error        */

#define HAL_SPI_ERROR_FRE           0x00000008U   /*!< FRE error        */

#define HAL_SPI_ERROR_DMA           0x00000010U   /*!< DMA transfer error   */

#define HAL_SPI_ERROR_FLAG         

0x00000020U   /*!< Flag: RXNE,TXE, BSY  */

you have MODF and CRC errors. Do you use CRC? And for MODF, RM0090 says:

In a slave device the MODF bit cannot be set.

I don't Cube.

JW

Steven Keeter
Associate III
Posted on December 18, 2017 at 14:25

Turned out that I had the NSS pin setup as software controlled instead of hardware input defined.  This condition caused the sync issue.