Skip to main content
chriskuku
Senior II
March 28, 2023
Question

Interrupt driven ADC conversion (LL) (STM32F103)

  • March 28, 2023
  • 3 replies
  • 1605 views

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)

This topic has been closed for replies.

3 replies

waclawek.jan
Super User
March 28, 2023

> 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
chriskukuAuthor
Senior II
March 28, 2023

> 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?

waclawek.jan
Super User
March 28, 2023

>> 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