cancel
Showing results for 
Search instead for 
Did you mean: 

Possible erroneous CubeMx code generation

GZini.16
Associate

I noticed that CubeMx (version 6.6.1 and earlier) when generating the code, may place the MX_DMA_Init() function after other ***_init functions that configure DMA registers. The problem is that those registers cannot be accessed 'before' enabling the DMA clock. For example here is a snippet of erroneous code:

  MX_ADC1_Init();
  MX_ADC3_Init();
  MX_I2C2_Init();
  MX_I2C3_Init();
  MX_SPI1_Init();
  MX_SPI2_Init();
  MX_DMA_Init();

In the example above the ADC1 and ADC3 peripheral use the DMA mode, but the DMA is not initialized yet. In attachment there is the whole main.c file containing the above snippet.

A possible workaround could be to impose the clock initialization before any other initialization:

  /* USER CODE BEGIN SysInit */
      /* Workaround for a CubeMx bug */
    __HAL_RCC_DMA2_CLK_ENABLE();
  /* USER CODE END SysInit */

1 ACCEPTED SOLUTION

Accepted Solutions
Ghofrane GSOURI
ST Employee

Hello @GZini.16​ ;

First let me thank you for posting.

I assume this is the exact same issue already reported to the development team and tracked by the

Internal ticket number: 132093

(This is an internal tracking number and is not accessible or usable by customers).

and that will be fixed as soon as possible.

I will keep you posted with updates.

Thx

Ghofrane

View solution in original post

2 REPLIES 2
Ghofrane GSOURI
ST Employee

Hello @GZini.16​ ;

First let me thank you for posting.

I assume this is the exact same issue already reported to the development team and tracked by the

Internal ticket number: 132093

(This is an internal tracking number and is not accessible or usable by customers).

and that will be fixed as soon as possible.

I will keep you posted with updates.

Thx

Ghofrane