cancel
Showing results for 
Search instead for 
Did you mean: 

Data transmit by UARD (DMA) with junk character

jlecl.1
Associate III

Dear eveyone,

I' little confuse..

I'm trying to send dat over uart from a nucleo board (F103 + FDTI). If a use "normal"method, it's work great.

I mean, i receive "1234567890" WITH a new line.

uint8_t start [20]= "1234567890 \n\r";
HAL_UART_Transmit(&huart1, start, sizeof(start),10);

But when i use DMA

uint8_t start [20]= "1234567890 \n\r";
HAL_UART_Transmit_DMA(&huart1, start, sizeof(start));

I get a lot of<NULL> character before data...

Maybe a need to reinit the buffer DMA ?

if you have an idea...

1 ACCEPTED SOLUTION

Accepted Solutions

Use strlen() not sizeof() for strings.

HAL DMA functions return IMMEDIATELY, make sure that the variable remains in SCOPE for the entirety of the transfer, and make sure not to start new transfers until the prior one has completed.

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

View solution in original post

4 REPLIES 4
jlecl.1
Associate III

error : the junk charater appears after the \n\r...

Use strlen() not sizeof() for strings.

HAL DMA functions return IMMEDIATELY, make sure that the variable remains in SCOPE for the entirety of the transfer, and make sure not to start new transfers until the prior one has completed.

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

recess... thanks a lot !

  1. uint8_t start[]= "1234567890 \n\r";
  2. HAL_UART_Transmit_DMA(&huart1, start, strlen(start));

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