Skip to main content
ranran
Senior
February 16, 2020
Question

Can we send and receive DMA UART at the same time ?

  • February 16, 2020
  • 3 replies
  • 1176 views

Hello,

I find in HAL_UART_Transmit_DMA the following code:

/* check that tx process is not already ongoing */
if (huart->gstate == HAL_UART_STATE_READY)
{
 .....
 return HAL_OK;
}
else
{
 return HAL_BUSY;
}

As far as I understand gstate, is for both tx and rx, so why we check that it is ready, instead of checking that there is no tx busy ?

Does it mean we can't send during reception of DMA in UART ?

Thank you

This topic has been closed for replies.

3 replies

Tesla DeLorean
Guru
February 16, 2020

HW should be capable of full-duplex operation with DMA

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Pavel A.
February 16, 2020

Examples by Tilen Majerle demonstrate TX and RX DMA simultaneously.

So, yes. But these examples do not use HAL API.

-- pa

berendi
Principal
February 17, 2020

HAL covers only a small fraction of the features of STM32 MCUs.

All STM32 MCUs have independent DMA channels for UART transmit and receive. Check the DMA request mapping / DMAMUX mapping tables in your reference manual.

DMA for transmit and receive can be enabled/disabled independently, see the DMAT/DMAR bits in UARTx->CR3.