AnsweredAssumed Answered

SPI DMA RX, polled TX hardfaults in HAL

Question asked by frackers on Jan 13, 2017
Latest reply on Jan 23, 2017 by Brunet.Julien

I've run out of DMA channels so I can't run SPI2 with DMA both ways. Since I'm talking to an external NOR flash chip where reading data is of much higher priority than writing I'd be happy with RX only DMA.


Setting up via CubeMX and assigning just RX DMA completes without error but when using HAL_SPI_Receive_DMA() the HAL code uses HAL_SPI_TransmitReceive_DMA() which hardfaults when trying to fill in the TX DMA data fields (not surprising as they haven't been allocated).


How do I set up via CubeMX to do HAL_SPI_Receive_DMA() for RX but HAL_SPI_Transmit() for TX?


I'm currently setting Direction=SPI_DIRECTION_2LINES which causes the call to HAL_SPI_TransmitReceive_DMA().


Direction=SPI_DIRECTION_1LINE looks like a non-starter as my hardware isn't set up like that.


If I use Direction=SPI_DIRECTION_2LINES_RXONLY, will I be able to poll the TX?