Skip to main content
frackers
Senior
January 12, 2017
Question

SPI DMA RX, polled TX hardfaults in HAL

  • January 12, 2017
  • 1 reply
  • 488 views
Posted on January 13, 2017 at 00:15

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?

Cheers

    This topic has been closed for replies.

    1 reply

    julien B
    ST Employee
    January 23, 2017
    Posted on January 23, 2017 at 17:29

    Hello,

    Yes, with your hardware configuration you can use '

    Direction=SPI_DIRECTION_2LINES_RXONLY' parameter.

    You will be able to poll Tx but after RX transfer completion.  (by using HAL_SPI_Transmit function).

    BRs,

    Julien.