Skip to main content
Steven Keeter
Associate III
Dec 15, 2017 5:47 PM UTC
Solved

Slave SPI Error

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. 

    This topic has been closed for replies.
    Steven Keeter
    Steven KeeterBest answer
    Associate III
    Dec 18, 2017 1:25 PM UTC
    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.

    2 replies

    waclawek.jan
    Super User
    Dec 17, 2017 11:08 PM UTC
    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
    Steven KeeterAuthorBest answer
    Associate III
    Dec 18, 2017 1:25 PM UTC
    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.