MX_DMA_Init order in the main.c file generated by STM32CubeMX, How to fix?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-07 5:05 AM
When DMA is used, the MX_DMA_Init shall always be called before any other HAL_***_Init (where *** is any peripheral with a HW dependency on DMA init code).
A regression was detected in the previous STM32CubeMX version 6.3.0 (STM32CubeIDE Version: 1.7.0 ) generating a wrong order of initialization functions.
This issue was fixed in the latest STM32CubeMX version 6.4.0. Thus, newly created project with this version will generate the correct initialization functions order.
Because the calling order is saved into the ioc file, the misplacement call to MX_DMA_Init() remains the same when trying to migrate automatically an old project from a buggy old version to the fixed version. The order stays the same and the generated code will be unfunctional.
For any old ioc file created by any STM32CubeMX version up to 6.3.0 included, hereafter some steps to overcome this misbehavior:
- Open the saved .ioc file (already created with 6.3.0 version) with any text editor installed in your machine and delete the line: ProjectManager.functionlistsort=....
- After saving the modification, re-open the .ioc file with latest CubeMX version 6.4.0 ( STM32CubeIDE Version: 1.8.0).
- Through Project Manager view > Advanced Settings tab, make sure that the initialization functions are correctly ordered and re-generate your project:
Solved! Go to Solution.
- Labels:
-
STM32CubeIDE
-
STM32CubeMX
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-06-29 4:54 AM
Hello,
This issue is fixed in STM32CubeMX latest release.
V6.6.0 is now available under this Link.
Thanks for your contribution.
Sara.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-01-12 4:21 AM
Many thanks for posting this. It saved my sanity after a couple of frustrating days trying to get DMA working for the LPUART and the ADCs.
There are many posts on stackoverflow etc. saying that the DMA must be initialised before the thing that uses it, e.g. ADCs. I had moved the DMA initialisation to position 3 in the start up order (after GPIO and SystemClock_Config) but DMA didn't work. When I moved it to position 2 as shown above, DMA worked. So there must be some interaction between the DMA and the SystemClock_Config initialisation that is preventing the DMA from running correctly.
tldr: Make sure the order is:
- GPIO
- DMA
- SystemClock_Config
- the rest.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-02-05 2:59 PM
I have just generated code with this IDE
STM32CubeIDE
Version: 1.8.0
Build: 11526_20211125_0815 (UTC)
OS: Linux, v.5.13.0-28-generic, x86_64 / gtk 3.24.20, WebKit 2.34.4
Java version: 11.0.11
CubeMX Version: 6.4.0-RC4
Build: 20211122-2105 (UTC)
Still: Wrong code. WTF ST?
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_ADC1_Init();
MX_DMA_Init();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-04-17 3:38 AM
Version 6.5.0 - same thing!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-04-17 11:44 AM
@PAkRad​ ,
is this a project newly started in version 6.5.0, or did you migrate a project created in older version of CubeMX?
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-04-17 11:53 AM
New project from scratch.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-04-17 11:53 AM
@Community member​ new project from scratch, actually to test the new version.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-04-25 9:12 PM
In latest version of cubeMX also same issue not resolved.
​
MX_GPIO_Init();
MX_ADC1_Init();
MX_DMA_Init();
​
Dma not working.​
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-04-25 9:17 PM
I deside to switch another MCU.
Lots of bugs and when you design your own product using ST s MCU then you can't get solution immediately.​
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-04-26 4:38 AM
Hello @parth kothiya​ , @PAkRad​ ,
I re-did the test from my part on an STM32H7 and I couldn't see the issue, the order is generated correctly.
Could you please share your ioc file and provide us with the exact scenario that led to this issue?
Thanks,
Sara.
