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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-10-26 3:01 PM
Test with STM32CubeIDE v1.10.1 containing STM32CubeMX STMicroelectronics 6.6.1.202207061420, creating project for NUCLEO-H7232ZG to use DMA to move data from memory to USART3.
Initialization order created by STM32CubeMX is still wrong:
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_ETH_Init();
MX_USART3_UART_Init();
MX_DMA_Init();
MX_USB_OTG_HS_USB_Init();
/* USER CODE BEGIN 2 */
In Project Manager - Advanced Settings - Generated Function Calls, the engry for MX_DMA_Init() is greyed out and cannot be moved, butthe MX_USART3_UART_Init() entry can be shifted down to correct the error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-10-28 2:18 AM
Exact, same issue for CubeMX, V6.5.0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-11-06 3:51 AM
@CJans.1​ provided a workaround, which may perhaps be a somewhat more persistent solution? I don't use Cube/CubeMX so can't judge.
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-02-01 12:08 AM
When you say not working, did you get zeros in the output? Or did you get in a deadlock​?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-03-01 9:26 AM
@Sara BEN HADJ YAHYA​ I got the same issue with cubeMx 6.6.1
I cannot change the order , for some reason DMa is greyed out and TIM1 cannot be moved neither
For the others TIM3 and TIM17 , i am able to change positions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-03-01 9:29 AM
good luck with that
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-03-01 9:30 AM
Not for me, aparently if you migrated the cubeMX from older versions DMA's place in the Advanced Settings menu cannot be changed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-03-01 9:32 AM
I do the same, to manually override initialization of the DMA, but every time i click autogenerate it tends to switch them back to the wrong order, it gets very tyring after a while.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-03-01 10:15 AM
You can edit the ioc file manually with a text editor.
Just look at this line:
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_CAN1_Ini...
Here you can modify the order of initialization.
You can move the DMA init to position 3 (change the numbers with it).
From now on, the CubeMX will generate correct code.
Johannes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-03-01 12:37 PM
Clearly you didn't even read the link Jan gave...

- « Previous
- Next »