cancel
Showing results for 
Search instead for 
Did you mean: 

A problem in switching the same ADC with different channels

Roshan
Associate III

Hi,

My purpose is to use the same ADC with different channels (one after another). I use stm32G4 with 170MHz clock speed. I want to check ADC values within a short time period. I use Baremetal. But unfortunately, I can only read one channel. it is not changing to the other channel.

There are some possibilities that I suspect are either time consuming is less therefore it won't change the channels. if not I might use the wrong coding. I am tight with time management, I could use the HAL functions to change the channels, but it would be great to help me find the proper way to sort out this issue.

Thanks in advance.

1 REPLY 1
Philippe Cherbonnel
ST Employee

Hello @Roshan​ ,

The most simple is to start from examples. There is no ADC example demonstrating multi ADC channel in STM32G4 FW package, but there are some in STM32L4 FW package (STM32L4 and STM32G4 have close feature set, a code can be easily ported from one to another).

You can download FW package from the web (https://www.st.com/en/embedded-software/stm32cubel4.html) or via CubeMX.

Then you can find multiple ADC channels examples:

Using ADC LL driver:

...\Firmware\Projects\NUCLEO-L496ZG\Examples\ADC\ADC_Sequencer

Using ADC HAL driver:

...\Firmware\Projects\NUCLEO-L496ZG\Examples_LL\ADC\ADC_MultiChannelSingleConversion

I you want to use bare metal code, you should start with LL driver.

Best regards

Philippe