2017-12-15 09:47 AM
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.
Solved! Go to Solution.
2017-12-18 05:25 AM
Turned out that I had the NSS pin setup as software controlled instead of hardware input defined. This condition caused the sync issue.
2017-12-17 03:08 PM
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
2017-12-18 05:25 AM
Turned out that I had the NSS pin setup as software controlled instead of hardware input defined. This condition caused the sync issue.