cancel
Showing results for 
Search instead for 
Did you mean: 

[SOLVED] STM32L0 possible bug with DMA

VLau
Associate III

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?

1 ACCEPTED SOLUTION

Accepted Solutions
VLau
Associate III

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);

View solution in original post

2 REPLIES 2
TDK
Guru

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
Associate III

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);