cancel
Showing results for 
Search instead for 
Did you mean: 

Interrupt driven ADC conversion (LL) (STM32F103)

chriskuku
Senior II

I want to gather 4 ADC values from peripheral potentiometers using an STM32F103C8T6 (blue pill). I've setup ADC1 using MX Cube. Enabled ADC1_2 NVIC global interrupt.

Now I'm a bit clueless how to proceed.

My idea is to start the ADC to do conversions. But how are the 4 channels read out? Does the ADC switch from one channel to the next automatically?

I found code snippets like this:

void ADC1_IRQHandler(void) {
    uint8_t i;
    if(LL_ADC_IsActiveFlag_EOC(ADC1)){
        adc_value[i] = LL_ADC_REG_ReadConversionData12(ADC1);
        i ++; 
       LL_ADC_ClearFlag_EOC(ADC1); 
     } else 
     if(LL_ADC_IsActiveFlag_EOS(ADC1)){
         i = 0; 
        LL_ADC_ClearFlag_EOS(ADC1); 
    }
}

Where can I read more about the meaning of ​EOC, EOS? (The above code seems to be for STM32F4x)

3 REPLIES 3

> Where can I read more about the meaning of ​EOC, EOS?

In the ADC chapter of Reference Manual, these are flags of ADC_SR register.

The 'F103 ADC is different from the 'F4 ADC. The Cube/LL functions may be somewhat misleading, as the 'F103 ADC does not have the EOS flag.

JW

chriskuku
Senior II

> the 'F103 ADC does not have the EOS flag.

The other way around: does not have the EOC flag, if I'm correct. At least the compiler didn't let me compile functions with EOC, just the EOS ones.

But when running in regular scan mode one has to use DMA, right?

>> the 'F103 ADC does not have the EOS flag.

>> 

> The other way around: does not have the EOC flag, if I'm correct.

0693W00000aJs1oQAC.png> At least the compiler didn't let me compile functions with EOC, just the EOS ones.

As I've said, the Cube/LL functions are misleading.

> But when running in regular scan mode one has to use DMA, right?

Not necessarily, but it's probably the most reasonable approach.

JW