SPI/DMA error on STM32F4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-05-07 7:45 AM
I'm trying to implement an SPI slave using DMA on a NUCLEO-F429ZI board. It basically works but when transactions from the master come too often (about 1ms) I start getting SPI overrun errors (i.e. HAL_SPI_ErrorCallback() is called). I would like to know if I'm doing anything wrong using HAL. I have attached my main.c and stm32f4xx_hal_msp.c. I've been struggling with this for a while to find the problem, so any help is appreciated. Thank you!
- Labels:
-
DMA
-
SPI
-
STM32F4 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-05-07 7:57 AM
Here is how I do:
DMA is in cyclic mode, no interrupt (TX and RX, SPI 4 wires)
Add EXTI interrupt on NSS signal, rise and fall edge. (even though HAL doesn't provide this feature, if NSS is HW Alternate function, however it works in the silicon)
Master should pause between NSS toggle and SCK activity for EXTI interrupt to be processed.
Maybe you init DMA on NSS rise or fall edge depends on application scheme.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-05-07 8:06 AM
Thanks for your reply. Do you suggest setting hspi1.Init.NSS = SPI_NSS_SOFT (not to use hardware NSS)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2019-05-07 9:42 AM
Behaviour of NSS for Slave is to automatically cut MISO MOSI if there are multiple slaves around.
Then it's an alternate function and you'll need to activate EXTI on this pin.
You'll get a callback interrupt when there is a falling edge (then you can setup the DMA pointers to the beginning of a rolling SRAM buffer), and process what you have received at NSS rising edge... this is application specific, the described scheme works for me. Others exists...
