cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMx initialization bug

CJans.1
Associate III

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

1 ACCEPTED SOLUTION
2 REPLIES 2
Piranha
Chief II

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