cancel
Showing results for 
Search instead for 
Did you mean: 

BUG: MX_DMA_Init(); wrongly placed by code generator --> HAL_UART_Transmit_DMA(..) does not work.

KnarfB
Principal III

STM32CubeIDE

Version: 1.1.0

Build: 4551_20191014-1140 (UTC)

File > New STM32 Project

Select for example NUCLEO-F042K6 board, leave default settings (STM32Cube_FW_F0 V1.11.0). But the bug exists for other boards/MCUs like STM32F432 too.

Initialize all peripherals with their default value? Yes.

Connectivity USART2:

 add USART2_RX DMA

 add USART2_TX DMA

 NVIC: enable USART2 global interrupt

Save all, look at generated code, main.c:

/* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_USART2_UART_Init();
  MX_DMA_Init();
  /* USER CODE BEGIN 2 */

MX_USART2_UART_Init() does not init properly because DMA block has no clock yet.

As a consequence, HAL_UART_Transmit_DMA( &huart2, "!", 1 ); does not output anything

Workaround: manually swap init code:

/* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_DMA_Init();
  MX_USART2_UART_Init();
  /* USER CODE BEGIN 2 */

or call MX_DMA_Init(); in a user code section upfront to avoid overwriting on code re-generation.

hth

KnarfB

1 REPLY 1
gflix
Associate II

I can confirm this for STM32F769I-DISCO (at least) as well. Took me several hours to find out :(

Had put MX_DMA_Init() into the user code section above and it works.