Showing results for 
Search instead for 
Did you mean: 

STM32L486Z6Tx as an SPI slave with DMA

Associate II

Hey I am using a STM32L486Z6Tx as an SPI slave, the device transfers blocks of 3588 bytes (512*7 + 4 byte checksum). At spi clock rates up to 1.2MHz everything works as planned. However at higher clockrates I still receive all my data, the checksum passes, the data is sent much quicker but the MCU freezes for approximately 100ms after the transmission. The SPI reports error code 32 "/*!< Error on RXNE/TXE/BSY/FTLVL/FRLVL Flag */". BSY flag not resetting is mentioned on the errata sheet for this chip. However how do I stop it from freezing the entire system while still using DMA?

I have a single priority zero interrupt attached to a 1ms timer, which periodically increments a timestamp. This is synchronised with an external pulse per second from a GPS module. During each of these "error" transfers my internal millisecond count goes out of sync by ~100ms. My highest priority interrupt and none of my freeRTOS tasks are being processed while this error occurs.

I have been unable to get the workaround mentioned on the Errata sheet 2.21.1 to work properly.

I am polling the until TXE flag is set, which I would rather be done in a non blocking way but I just want it to work for now.



itflag  = hspi3.Instance->SR;


The next step is "disable SPI by clearing SPE while the last data transfer is still on going,"


Doing so results in zero data being transferred. Note the __HAL_SPI_DISABLE macro clears the SPI_CR1_SPE bit .

How can I prevent the microcontroller from stalling during fast SPI transfers? I would be happy to ignore all error flags as long as the error didn't stall the system. The master toggles a GPIO for the checksum status so I don't need to rely on the error bits.