2022-10-26 02:44 PM
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
2022-10-26 06:56 PM
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
2022-10-27 11:03 PM
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
2022-10-28 12:21 AM
after >> generate code
look in main.c -> MX_ADC1_Init(void)
and you should see somthing like this:
Cube should set the ADC as you did in configuration;
the "set" - functions are in xx_ll_adc.h .