cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMx and configuring ADC channel(s)

Taxara
Associate III

Hi Guys,

Im struggling in getting a good way to work with cubemx and multi channel ADC. I want to be able to only change the cubemx file whenever there is a hardware change. Currently i cannot do so because in my firmware i am using HAL_ADC_ConfigChannel() to change adc configurations (i have 5 channels and need 3 to sample at the same time at the max speed, other two i sample seperatly and later on). However the ADC_ChannelConfTypeDef.Channel needs to know the ADC channel.

Does Cubemx have a way to create variables for adc channels (currently i use variable ADC_CHANNEL_x ) ? Or is there a way to grab the channel from a user label?

Kind regards,

Taxara

1 ACCEPTED SOLUTION

Accepted Solutions
Houssem CHAABANI
Senior II

Hi @Taxara​ ,

You can select your MCU and then navigate to Analog.

Choose the ADC that you want to activate , then enable the channels that you want.

After this you have an ADC configuration on many channels

You can define you variables in User Constants.

Hope that this helps you

Houssem

View solution in original post

2 REPLIES 2
Houssem CHAABANI
Senior II

Hi @Taxara​ ,

You can select your MCU and then navigate to Analog.

Choose the ADC that you want to activate , then enable the channels that you want.

After this you have an ADC configuration on many channels

You can define you variables in User Constants.

Hope that this helps you

Houssem

Thank you, this was exactly where i was looking for! Working with cubemx some time now and totally missed the "user constants" field...