cancel
Showing results for 
Search instead for 
Did you mean: 

stm32 UART-DMA one character transfer problem

mdg82
Associate
Posted on June 01, 2015 at 14:21

Hello! I'm using STM32F407 processor. When I'm trying to send 1 byte via USART-DMA (for example 0x72) I get two bytes ''72 72'' in terminal.If I send two or more bytes everything is okay. If I send something from terminal I can't receive one byte, only two or more bytes can be received. Maybe someone can help to solve this problem. Thanks.

3 REPLIES 3
qwer.asdf
Senior
Posted on June 01, 2015 at 14:43

Not without seeing your code. What library are you using?

Posted on June 01, 2015 at 15:48

Aren't there more efficient ways to send one character? Seems like DMA would add a lot of overhead in this case.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
mdg82
Associate
Posted on June 02, 2015 at 09:25

Here's the function that sends buffer

uint32_t USART_Send(USART_Handle* handle, uint8_t *data, uint32_t size)

{

    assert_param(handle);

    assert_param(handle->instance);

    assert_param(data);

    assert_param(size <= sizeof(handle->buffer_tx));

    

    if(handle->buffer_tx_busy)

        return 0;

    handle->buffer_tx_busy = 1;

    

    memcpy(handle->buffer_tx, data, size);

    

    /* Configure DMA Stream source address */

  handle->dma_tx_instance->M0AR = (uint32_t)handle->buffer_tx;

    /* Configure DMA Stream data length */

    handle->dma_tx_instance->NDTR = size;

    

    LEDS_ON_GREEN(handle->params.led);

    

    DMA_Cmd(handle->dma_tx_instance, ENABLE);

    if(!_DMA_Cmd(handle->dma_tx_instance, ENABLE) && handle->buffer_tx_busy)

    {

        Errors.Error_uart = ERROR_FAIL_UART_DMA_CMD;

        return 0;

    }

    

    return size;

}