cancel
Showing results for 
Search instead for 
Did you mean: 

How do you change an ADC channel at the low level

SJohn.5
Associate II

Hello,

I am working with the low level drivers and trying to configure an ADC to read 2 channels via the Cube IDE. I am triggering the read of the ADC via a 1 ms internal timer interrupt. Note I am trying to do this read via polling and not via interrupt of DMA.

I have had a thorough look through the low level driver/stm32L5xx_ll_adc.h and I can't find anything that suggests how you actually select the external channel into the ADC.

I have attached a picture of the ADC configuration in the CUBE IDE and a picture of the external channel input into the ADC as per the STML552XX reference manual. Note, I am using an STM32L562VET6Q.

Any help would be greatly appreciated.

Kind regards,

Sam

3 REPLIES 3
raptorhal2
Lead

After searching through stm32l5xx_ll_adc.c, didn't find any such function.

Suggest register programming to set and clear the adc sequence registers.

Cheers, Hal

SJohn.5
Associate II

Thank you for your response. Yes, I think you are correct. You would have to directly set and clear the ADC registers if you were to approach it this way. However, I found doing it via an injection conversion worked for me as I only needed to read from three of the ADC channels. Alternatively, if you needed to read a larger number of channels I think you would need to utilise DMA.

Cheers,

Sam

AScha.3
Chief II

after >> generate code

look in main.c -> MX_ADC1_Init(void)

and you should see somthing like this:

0693W00000VOKiKQAX.pngCube should set the ADC as you did in configuration;

the "set" - functions are in xx_ll_adc.h .

If you feel a post has answered your question, please click "Accept as Solution".