cancel
Showing results for 
Search instead for 
Did you mean: 

Transfer Error (invalid Data) with USART1 & DMA

RBarr.1
Associate II

Hello,

I setup USART1 using DMA with a STM32G071 & using HAL lib.

Currently, i try to send uint8_t TxBuffer[7]={0x16,0x07,0x98,0x09,0x00,0x00,1B}.

Transfert is done using HAL_UART_Transmit_DMA(&huart1, &TxBuffer[0], 7) and i have well manage the required interrupt signals because it send 7 bytes on Tx signal multiples times & not only ones;

but on the Tx Signal when i look the data transmitted by the DMA to USART, i can see the folowing data {0x16,0x07,0x98,0x03,0xD0,0x00,00}... 3 first bytes are always right but the other bytes values are always wrong...

It look like that DMA was badly configurate (wrong memory increment). but it seem right (see below):

hdma_usart1_tx.Instance = DMA1_Channel3;

hdma_usart1_tx.Init.Request = DMA_REQUEST_USART1_TX;

hdma_usart1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;

hdma_usart1_tx.Init.PeriphInc = DMA_PINC_DISABLE;

hdma_usart1_tx.Init.MemInc = DMA_MINC_ENABLE;

hdma_usart1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;

hdma_usart1_tx.Init.MemDataAlignment = DMA_PDATAALIGN_BYTE;

hdma_usart1_tx.Init.Mode = DMA_NORMAL;

hdma_usart1_tx.Init.Priority = DMA_PRIORITY_LOW;

Do you have any idea what it happens here?

Thanks a lot

4 REPLIES 4

Is this reproducible?

What's your hardware and how do you receive the data exactly?

What's the primary clock source of STM32?

JW

RBarr.1
Associate II

Yes is it reproductible.

I use a stm32G071G8 mcu on custom PCB (i dont'use a nucleo board).

The data are sending out the MCU on a Tx Line & i check it with an Oscilloscope.

I have already Try a transfer Without DMA Using HAL_UART_Transmit(&huart1, &TxBuffer[0], 7,TIMEOUT) & it work well the data values are always correct.

I have also try to send a bigger buffer to check if the phenomena happens at the half of the buffer... but no, it always happens after 3 byte (it look more like a memory increment issue)

RBarr.1
Associate II

I forgot I use internal clock sources with HCLK 55MHZ

No idea.

Sounds like some FIFO-related issue (?)

Try to rewrite it as a minimal program without Cube/HAL, using direct register access.

JW