Hey guys I have never worked with an ADC so want to ask a basic question
I need to use three channels of ADC...
1) Will the conversion of the three channels run in parallel??
2) will i get a single interrupt for completion of adc conversions or an individual interrupt for each channel??
ADC working
Moderator: RoccoMarco
Re: ADC working
1) This depends on the MCU you are using. Most MCUs come with one ADC which has multiple channels. The channels are multiplexed and therefore the conversations work in parallel. However the newer / bigger MUCs like the STM32F4 come with two or even three independend ADCs. Therefore possible that you can make three conversations in parallel.
2) Mostly the callback function of the ADC driver is used. You can use the same or different callback routines for each ADC channel configuration.
~ Tectu
2) Mostly the callback function of the ADC driver is used. You can use the same or different callback routines for each ADC channel configuration.
~ Tectu
-
Faisal Mehmood
- Posts: 25
- Joined: Sat Jan 26, 2013 10:18 pm
Re: ADC working
em using stm32f4 discovery
the adcgrpcfg structure is programmed as:
Here is a single adccb function as callback.. how can i add individual callbacks for each channel?
the adcgrpcfg structure is programmed as:
Code: Select all
static const ADCConversionGroup adcgrpcfg = {
FALSE,
ADC_GRP1_NUM_CHANNELS,
adccb,
NULL,
/* HW dependent part.*/
0,
ADC_CR2_SWSTART,
ADC_SMPR1_SMP_AN11(ADC_SAMPLE_56) | ADC_SMPR1_SMP_SENSOR(ADC_SAMPLE_144),
0,
ADC_SQR1_NUM_CH(ADC_GRP1_NUM_CHANNELS),
0,
ADC_SQR3_SQ2_N(ADC_CHANNEL_IN11) | ADC_SQR3_SQ1_N(ADC_CHANNEL_SENSOR)
};Here is a single adccb function as callback.. how can i add individual callbacks for each channel?
Re: ADC working
You can assign a different callback to each conversion group separately by passing a different ADCConversionGroup to the adcStartConversion() routine.
tl;dr -> simply group your channels by the callback you want for them and create unique ADCConversionGroup structures.
Also, you might want to check out this thread.
~ Tectu
tl;dr -> simply group your channels by the callback you want for them and create unique ADCConversionGroup structures.
Also, you might want to check out this thread.
~ Tectu
-
Faisal Mehmood
- Posts: 25
- Joined: Sat Jan 26, 2013 10:18 pm
Re: ADC working
No problem. You're welcome and I am always totally happy when I can help other people.
Feel free to ask future questions, but make sure you don't miss the documentation completely
~ Tectu
Feel free to ask future questions, but make sure you don't miss the documentation completely
~ Tectu
-
Faisal Mehmood
- Posts: 25
- Joined: Sat Jan 26, 2013 10:18 pm
Re: ADC working
hahaha yeah surely
my practise is to check stm32f4 reference manual and chibios hal reference for any problem.... I ask you guys if the official documents can't clear my misunderstanding
my practise is to check stm32f4 reference manual and chibios hal reference for any problem.... I ask you guys if the official documents can't clear my misunderstanding