Skip to main content
Visitor II
March 30, 2020
Solved

How to use HAL to leave the UART DMA in idle mode?

  • March 30, 2020
  • 2 replies
  • 948 views

Hi,

I'm trying to develop a module where information from a buffer is read by DMA and sent through UART, but the information is put in the buffer without a constant rate and it might happen that the buffer is empty, if that happened, I understand that the DMA would keep working sending information which has already been sent.

Then my initial idea is to check whether the buffer has more information in the HAL_UART_TxCpltCallback() and in case that there is no more information disable it, and whenever there's data in the buffer, call HAL_UART_Transmit_DMA.

I've seen HAL_UART_DeInit, but I'm also using the uart RX and then I think both RX and TX would stop working, which is not ok for me.

Then, what do you suggest for tackling this issue?

Best regards,

Nicolas.

    This topic has been closed for replies.
    Best answer by mur

    DFuchs, thanks for your answer.

    For any other person with the same issue, the conclusion is that if the DMA is configured in normal mode, the transmission just ends so the user does not have to disable it.

    2 replies

    Visitor II
    March 30, 2020

    Hi,

    i can only speak about the STM32H743.

    When i'm starting an DMA transfer (memory to peripheral) i set the number of data to transmit (register DMA_SxNDTR). When this register reaches zero i can send the next data.

    murAuthorAnswer
    Visitor II
    April 1, 2020

    DFuchs, thanks for your answer.

    For any other person with the same issue, the conclusion is that if the DMA is configured in normal mode, the transmission just ends so the user does not have to disable it.