Skip to main content
VLau
Associate III
August 10, 2021
Solved

[SOLVED] STM32L0 possible bug with DMA

  • August 10, 2021
  • 2 replies
  • 1653 views

Hey!

I'm trying sending message over UART with DMA with following code and CubeMX configuration (attached pictures)

char welcome[] = "hi!\r\n";
 HAL_UART_Transmit_DMA(&huart2, (uint8_t*) welcome, strlen(welcome));

Nothing else is changed.

MCU doesn't send anything. The "HAL_UART_Transmit_IT" & "HAL_UART_Transmit" functions work.

I'm using NUCLEO-L010, tried exact same configuration with another NUCLEO-F303 board and "HAL_UART_Transmit_DMA" works as expected.

Code doesn't stuck or give any error messages during debug.

What did I miss?

This topic has been closed for replies.
Best answer by VLau

Ok, just found the answer.

The order in which modules are initialized matters. DMA initialization followed by USART initialization (I had vice versa). Order can be changed in CubeMX.

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_DMA_Init(void);
static void MX_USART2_UART_Init(void);

2 replies

TDK
August 10, 2021

What is the return value from HAL_UART_Transmit_DMA?

Might get an example up and running if you're super stuck.

https://github.com/STMicroelectronics/STM32CubeL0/tree/a7b74aed35ecb7baeadeb16107aa8fddb6823589/Projects/NUCLEO-L011K4/Examples/UART/UART_HyperTerminal_DMA

"If you feel a post has answered your question, please click ""Accept as Solution""."
VLau
VLauAuthorBest answer
Associate III
August 10, 2021

Ok, just found the answer.

The order in which modules are initialized matters. DMA initialization followed by USART initialization (I had vice versa). Order can be changed in CubeMX.

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_DMA_Init(void);
static void MX_USART2_UART_Init(void);