2021-08-10 06:16 AM
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?
Solved! Go to Solution.
2021-08-10 06:46 AM
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);
2021-08-10 06:43 AM
What is the return value from HAL_UART_Transmit_DMA?
Might get an example up and running if you're super stuck.
2021-08-10 06:46 AM
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);