Skip to main content
CJans.1
Associate III
November 6, 2022
Solved

STM32CubeMx initialization bug

  • November 6, 2022
  • 2 replies
  • 1570 views

I found the following bug:

STM32CubeMX generates the following initialization code:

 /* Initialize all configured peripherals */
 MX_GPIO_Init();
 MX_DCMI_Init();
 MX_I2C1_Init();
 MX_I2C2_Init();
 MX_UART5_Init();
 MX_USART1_UART_Init();
 MX_DMA_Init();
 MX_USB_DEVICE_Init();

The problem is that MX_DCMI_Init() is also initializing the corresponding DMA. But the DMA clock is not enabled yet! It will be enabled by MX_DMA_Init().

The result is that the DMA for the DCMI is not correctly initialized and the code does not work.

When I enable the clock just before the initialization it works:

 /* USER CODE BEGIN SysInit */
 
 __HAL_RCC_DMA2_CLK_ENABLE();
 
 /* USER CODE END SysInit */
 
 /* Initialize all configured peripherals */
 MX_GPIO_Init();
 MX_DCMI_Init();
 MX_I2C1_Init();
 MX_I2C2_Init();
 MX_UART5_Init();
 MX_USART1_UART_Init();
 MX_DMA_Init();
 MX_USB_DEVICE_Init();

This topic has been closed for replies.

2 replies

Piranha
Principal III
November 6, 2022

This is a relatively nice and reliable workaround for that never-ending CubeMX idiocracy.