Skip to main content
Philip Westphal
Associate II
June 1, 2018
Question

UART DMA not working for some reason

  • June 1, 2018
  • 8 replies
  • 1765 views
Posted on June 01, 2018 at 17:54

Hello again. I've been trying to get my mcu to transfer a buffer via UART to my computer with the help of DMA.

for some reason, it does not appear to be working. I think my computer recognizes it correctly just as when I am 

not using DMA but for some reason i am not receiving the information on my computer.  

Thank you very much for your help.

    This topic has been closed for replies.

    8 replies

    T J
    Senior III
    June 1, 2018
    Posted on June 01, 2018 at 22:15

    Did you enable the Uart Interrupt ?

     and start the DMA ?

        HAL_UART_Receive_DMA(&huart1, (uint8_t *)Usart1RxDMABuffer, U1RxBufSize);

    Philip Westphal
    Associate II
    June 2, 2018
    Posted on June 02, 2018 at 01:31

    Thank you for your reply. I should have given more information. I apologize. I am using the discovery board for the stm32f072rbt6. I am trying to use the dma function to send values from the adc to my computer. It does work without dma (only hal_transmit_fs) but not with it.

    To answer your questions. I did enable the Uart interrupt via Cube and I did start the dna. My main is attached to the original question as a text file. But just to be sure I have attached the settings below.

    //start dma

    HAL_UART_Transmit_DMA(&huart1, (uint8_t *)bufftr, sizeof(bufftr));

    //Interrupt settings

    0690X0000060L46QAE.png
    T J
    Senior III
    June 2, 2018
    Posted on June 02, 2018 at 03:26

    I use this code to transmit if I have data in my Tx Buffer, much like your senerio.

       if (TxDMA1BufHasData) {

            char uartState = HAL_UART_GetState(&huart1);

            if ((uartState == HAL_UART_STATE_READY) || (uartState == HAL_UART_STATE_BUSY_RX)) {

                TxDMA1BufHasData = false;         // sending now

                if(HAL_UART_Transmit_DMA(&huart1, (uint8_t *)Usart1TxDMABuffer + U1TxBufferPtrOUT, U1TxBufferPtrIN - U1TxBufferPtrOUT) == HAL_OK) {

                    U1TxBufferPtrOUT = U1TxBufferPtrIN;

                    Usart1TxDMABuffer[U1TxBufferPtrIN] = 0;     // null terminator, not needed

    :(

                }

                else {

                    _Error_Handler(__FILE__, __LINE__); /* Transfer error in transmission process */

                }

            }

        }