cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G4 ADC DMA fails when MX_ADC1_Init is called before MX_DMA_Init

BPaik
Senior

I have setup ADC1 on an STM32G4 in scan mode where the start of conversions is initiated by a timer. I have also setup the DMA in circular mode and configured it such that the ADC results are transferred to an array every time the scan conversion completes. The code generated by CubeMX calls the MX_ADC1_Init() before MX_DMA_Init(). In this order, the DMA doesn't update my array values. However, when I change the order of initialization so that MX_DMA_Init() is called beore MX_ADC1_Init(), everything seems to work fine. I looked in the code briefly, but couldn't figure out why the order of initialization matters. It is also problematic because I have to manually change the order of initialization every time I regenerate code using CubeMX.

1 ACCEPTED SOLUTION

Accepted Solutions
Amel NASRI
ST Employee

Hi @BPaik​ ,

I looked in the code briefly, but couldn't figure out why the order of initialization matters.

Simply because MX_ADC1_Init() tries to update some DMA related registers while its clock isn't activated (with MX_DMA_Init()).

This is well explained by @TDK​  in this discussion.

It is a known regression in STM32CubeMX 6.3.0. I think that it will be fixed soon. @Khouloud OTHMAN​  can confirm this.

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

2 REPLIES 2
Amel NASRI
ST Employee

Hi @BPaik​ ,

I looked in the code briefly, but couldn't figure out why the order of initialization matters.

Simply because MX_ADC1_Init() tries to update some DMA related registers while its clock isn't activated (with MX_DMA_Init()).

This is well explained by @TDK​  in this discussion.

It is a known regression in STM32CubeMX 6.3.0. I think that it will be fixed soon. @Khouloud OTHMAN​  can confirm this.

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hello @BPaik​ ,

As already mentioned by @Amel NASRI​ , this issue was already detected with other STM32 MCUs and raised to our development team to be reviewed and fixed as soon as possible.

I'll surely keep you posted with the updates.

Sorry for any inconvenience that this may cause.

Khouloud.