cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with CubeMx 6.12 + adc5 + dma

giancarlofi
Associate III


In my project I use 4 adc, managed with the same code. With adc5, and two channels, I had a problem: I read two equal values, that is, the second was equal to first channel.
After several searches I discovered that, in the adc.c file created by cubemx, in the section relating to adc5,

the line -->sConfig.Channel = ADC_CHANNEL_2;<-- was missing

First channel configuration

/** Configure Regular Channel */
sConfig.Channel = ADC_CHANNEL_1;
sConfig.Rank = ADC_REGULAR_RANK_1;
sConfig.SamplingTime = ADC_SAMPLETIME_2CYCLES_5;
sConfig.SingleDiff = ADC_SINGLE_ENDED;
sConfig.OffsetNumber = ADC_OFFSET_NONE;
sConfig.Offset = 0;
if (HAL_ADC_ConfigChannel(&hadc5, &sConfig) != HAL_OK)
{
Error_Handler();
}

/** Configure Regular Channel */
Second channel configuration
--> sConfig.Channel = ADC_CHANNEL_2; <<-- this was not there
sConfig.Rank = ADC_REGULAR_RANK_2;

I have re-done the configuration with Cubemx several times but the problem remains
Is it a bug?
Can I do something?
It is annoying to have to remember to manually add a line of code in adc.c when I change the configuration in Cubemx.
Thanks

8 REPLIES 8
Imen.D
ST Employee

Hello @giancarlofi 

Please share your ioc file to reproduce this case.

You can check the "Keep User Code when regenerating" option and change your code in the USER CODE sections, it will be kept as it is, but this option applies only to user sections.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

Hi Imen, I attach the ioc file.

My code is in a subdirectory of the project. Only one my function is in the main loop.

The option 'keep user code...' is selected.

By

 

 

Imen.D
ST Employee

Hi @giancarlofi,

I checked your ioc file and the line for ADC_CHANNEL_2 is generated:

ImenD_0-1724403744446.png

Make sure to use the latest release of STM32CubeMX and STM32CubeG4 firmware package.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

Hi Imen, thank you for your response but the adc is hadc5 not hadc2.

I redid the file generation several times, but the result did not change.

Imen.D
ST Employee

Hi @giancarlofi ,

You are right. I escalated this issue internally for fix (via internal ticket number 189389)

(PS: The internal ticket number 189389 is only for reference, not available outside of ST)

Thank you for your contribution.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

Thanks Imen,

to get information on the bug resolution can i follow some maillist or forum?

We will be back to you when we fix the issue, or you can follow the Main fixed issues for coming releases via wiki page: STM32CubeMX errata - stm32mcu.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen