AnsweredAssumed Answered

Distinguish multiple ADC channels STM32F0

Question asked by hayford.tim on Nov 13, 2015
Latest reply on Nov 13, 2015 by hayford.tim
I'm developing an application that requires me to quickly and constantly reading 5 ADC channels.
I'm using the STM32F030F4P6. I set it up to do a continuous conversion and told it the 5 ADC channels I need. I have it set to trigger an interrupt at the end of each conversion so I can handle the data.  

The problem I am running into is that I can't figure out how to tell which channel's data I am looking at. Since any channel causes the same interrupt, I don't know how to trace it back and tell which one triggered it.

Here's the code I'm using to set up my ADCs

 
void adc_window_init() {
RCC->APB2ENR |= RCC_APB2ENR_ADC1EN;
RCC->CR2 |= RCC_CR2_HSI14ON;
ADC_SPIN((RCC->CR2 & RCC_CR2_HSI14RDY) == 0);
ADC1->CR |= ADC_CR_ADCAL; //Enable calibration
ADC_SPIN((ADC1->CR & ADC_CR_ADCAL) != 0);
ADC1->CR |= ADC_CR_ADEN; //Enable ADC
ADC_SPIN((ADC1->ISR & ADC_ISR_ADRDY) == 0);
ADC1->IER |= ADC_IER_EOCIE; //Enable End of conversion interrupt

ADC1->CFGR1 = 0b00000000000000000010000000000000; //12 bit resolution, continuous mode
ADC1->SMPR = 4; // 41.5 Clk cycles for sampling
ADC1->CHSELR = ADC_CHSELR_CHSEL0 | ADC_CHSELR_CHSEL1 | ADC_CHSELR_CHSEL2 | ADC_CHSELR_CHSEL3 | ADC_CHSELR_CHSEL4 ;
ADC1->CR |= _BV(2); // Start
NVIC->ISER[0] |= _BV(ADC1_COMP_IRQn);
}

Any help would be appreciated. 

Outcomes