cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U031 SPI receive data of arbitrary length

FlokRo
Visitor

Greetings!
I am using the STM32U031 with STM32CubeMX HAL as an SPI Slave and would like to receive data that has variable length (max 50 bytes). I am using software NSS and my current approach is to start a DMA Rx/Tx transfer (using HAL_SPI_TransmitReceive_DMAof the maximum expectable length when NSS goes down (in the corresponding GPIO callback) and to abort the transfer when NSS rises again (using HAL_SPI_Abort). From a functional perspective this approach works, but the abortion of the Transfer currently takes about 1.4 ms (at 8 MHz MSI Clock). As a result,  the answer to the Master is not ready when it clocks again.

 

Is there anything I can do better / different to improve the timing?


I know that using HAL_SPI_Receive_DMA instead of HAL_SPI_TransmitReceive_DMA for Rx would reduce the time required for aborting the transfer, but then it seems that I have no control over the data that is transmitted while receiving, which causes trouble on the Master side (which is outside of my control).

0 REPLIES 0