Skip to main content
Taxara
Associate III
January 25, 2021
Solved

CubeMx and configuring ADC channel(s)

  • January 25, 2021
  • 1 reply
  • 2161 views

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

This topic has been closed for replies.
Best answer by Houssem CHAABANI

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

1 reply

Houssem CHAABANI
Houssem CHAABANIBest answer
Visitor II
January 25, 2021

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

Taxara
TaxaraAuthor
Associate III
January 25, 2021

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