cancel
Showing results for 
Search instead for 
Did you mean: 

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

ranran
Senior II

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

3 REPLIES 3

HW should be capable of full-duplex operation with DMA

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Pavel A.
Evangelist III

Examples by Tilen Majerle demonstrate TX and RX DMA simultaneously.

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

-- pa

berendi
Principal

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.