cancel
Showing results for 
Search instead for 
Did you mean: 

code generated calls MX_DMA_Init too late, after MX_SPI_Init

mmalex
Associate II

I'm a relatively new user but am just about getting up to speed with STM32 family and STM32CubeIDE. I love that there is a gui that helps to generate code to configure peripherals, however I am learning to distrust some of the detals of the code generation :(

One that just cost me a few hours of head scratching:

I was setting up an STM32L4R5ZI (nucleo) board as a full duplex SPI slave, and had configured all the pins & settings correctly. Blocking mode HAL_SPI_TransmitReceive was working, but when I configured DMA and used the _DMA variant of the function, I could not get any of the DMA complete interrupts or callbacks to fire.

I compared my code over and over again to an example, until I randomly looked at the initialization code that Cube had generated for me, which included this block:

 MX_GPIO_Init();

 MX_LPUART1_UART_Init();

 MX_USART3_UART_Init();

 MX_USB_OTG_FS_PCD_Init();

 MX_SPI1_Init();

 MX_DMA_Init();

I found that if I moved the DMA_Init line before the SPI Init line, everything worked as expected.

However, every time I regenerate code, it moves the DMA init back to the bottom.

I am guessing this is a bug in the cube code generation? certainly as a new user of this platform, i'm not confident to point fingers; but it's frustrating that it gives the appearance of a helpful platform, but bugs like this really stop you from making progress, as you question everything first :(

What can I do to force STMCube to move the DMA_Init line earlier?

and if this is a bug, how quickly are these sorts of things typically fixed? what should I do in the meantime?

Thanks!

I appreciate

1 ACCEPTED SOLUTION

Accepted Solutions
Herve PIERROT
ST Employee

in MX, in the Project Manager->Advanced Settings, you have a table "Generated Function Calls" with each init function listed in order of creation.

In fact, it may not be always visible (it has already been reported), but at the bottom of this box, that can be a bit far from the end of the table, need to

use the scrollbar, you will find some buttons to move up/down the selected line in the list to change the ordering.

View solution in original post

3 REPLIES 3

This is an already known bug in CubeMX, try to search here on forum.

JW

@Amel NASRI​  , wouldn't it be worth putting up a sticky post regarding this issue?

mmalex
Associate II

thanks! I did search a bit but didnt find it :( I also looked in the release notes, not there either.

is there a workaround?

Herve PIERROT
ST Employee

in MX, in the Project Manager->Advanced Settings, you have a table "Generated Function Calls" with each init function listed in order of creation.

In fact, it may not be always visible (it has already been reported), but at the bottom of this box, that can be a bit far from the end of the table, need to

use the scrollbar, you will find some buttons to move up/down the selected line in the list to change the ordering.