Page 1 of 1

Doubt about ADCConversionGroup Structure

Posted: Mon Mar 12, 2012 11:04 am
by sapan
Hi,

In Sample code ADCConversionGroup is defined as follow

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 first four fields are circular buffer enable/disable, number of channels to poll, call back function and error pointer.

In HW dependent part CR1 and CR2 are configured first.
Then Sampling time is set for Channel AN11 (56 cycles) and Temperature Sensor (144 cycles) in SMPR1 register.
SMPR2 register is defined as zero.
I am not able to understand values defined in last three registers ADC_SQR1, ADC_SQR2 and ADC_SQR3

Sapan

Re: Doubt about ADCConversionGroup Structure

Posted: Mon Mar 12, 2012 11:50 am
by Giovanni
SRQ1...SQR3 contain the number of channels that are part of the group (ADC_SQR1_NUM_CH(ADC_GRP1_NUM_CHANNELS)) and the channels to be converted (ADC_SQR3_SQ2_N(ADC_CHANNEL_IN11) | ADC_SQR3_SQ1_N(ADC_CHANNEL_SENSOR)), IN11 and the temperature sensor in this case.

This part is pretty low level, you should refer to the STM32 RM for a full description of the registers.

Giovanni

Re: Doubt about ADCConversionGroup Structure

Posted: Mon Mar 12, 2012 2:02 pm
by sapan
Got it...wanted to configure PC1 and PA0 as analog inputs...done now...:) thanks