cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U083C-DK UART Rx with DMA adds a zero value byte to first buffer location when it isn't there

flaming_wingnut
Associate

Using the STM32U083C-DK discovery board with STM32CubeIDE and set up the project using the Device Configuration Tool.

Set up a simple program to transmit 8-bit data out one UART using interrupts and receive it in another UART using DMA.

Variables used:

flaming_wingnut_0-1731523874099.png

Relevant main.c code:

flaming_wingnut_1-1731523963184.png

The UARTEx handler toggles the green LED when the Idle event is detected.

flaming_wingnut_2-1731524045824.png

The program works, but the RxDataLen size is 9 bytes, not 8 and the first buffer byte is always 0.  The remaining bytes are correct per my predefined array.  If I loop this sequence, the results are always the same.

flaming_wingnut_4-1731524699513.png

A scope screenshot clearly shows there isn't a leading 0x00 byte being sent.  Purple trace is the LED toggle on Idle.

tek00012.png

I've tried adding delays between the DMA and transmit and it doesn't change the result.  If I read the USART3->RDR register before the HAL_UARTEx_ReceiveToIdle_DMA(), then it works correctly (8 bytes, UART3_RxBuffer1[0] = 0x12).  It doesn't seem like I should have to do that.

Is there a better way to fix this?

 

0 REPLIES 0