2024-07-17 06:20 PM - last edited on 2024-07-17 11:09 PM by Peter BENSCH
Hi,
I am just trying to run adc in discontonous mode to measure some voltate from two resistor divider connected on channel 6 (PA1) and channel 7 (PA2) and also Vref from internal channel 12 as per datasheet. see below screenshot from DS14581- Rev2
below is the code
RCC->APBENR2|=RCC_APBENR2_ADCEN; //enable adc clock
ADC1_COMMON->CCR=ADC_CCR_VREFEN; //
ADC1->CFGR2|=(1<<ADC_CFGR2_CKMODE_Pos); clock divide by 2
ADC1->CFGR1|=ADC_CFGR1_DISCEN; // discontinuos mode
ADC1->SMPR=0x05; //sampling time setting
ADC1->CR=ADC_CR_ADCAL|ADC_CR_ADVREGEN; // start adc calibration
while((ADC1->CR)&(ADC_CR_ADCAL)) // wait while adc calibraion is not complete
{};
ADC1->CR=ADC_CR_ADEN; // ADC enable
ADC1->CHSELR=ADC_CHSELR_CHSEL6|ADC_CHSELR_CHSEL7|ADC_CHSELR_CHSEL12;// select channels to be converted
ADC1->CR=0x05; //ADC enable and start conversion.
uint16_t adc_data=ADC1->DR;
I have tested that when I choose below configuration for channels . I get the desired results.
ADC1->CHSELR=ADC_CHSELR_CHSEL5|ADC_CHSELR_CHSEL6|ADC_CHSELR_CHSEL11;
So that clearly means that ADC channel 5 is connected to PA1, ADC channel 6 is connected to PA2 and VREFINT is ADC channel 11 in contrast to what is mentioned in the reference manual RM0503 Rev2. and the datasheet of the product.
Please confirm.
2024-08-29 03:06 AM
Hello @KSB ,
First, I apologize for my late reply.
Thank you for bringing this issue to our attention.
I confirm this is a documentation issue. In the DS14581- Rev2, ADC channels numbering starts by mistake from ADC_IN1 instead of ADC_IN0.
I reported this typo internally
Internal ticket number: 182169 (This is an internal tracking number and is not accessible or usable by customers).
Thank you.
Kaouthar
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-08-29 05:20 AM
First, really sorry about the difficulties due to documentation misalignment.
Documents are ongoing update to have it fixed.