AnsweredAssumed Answered

ADC channel reading

Question asked by amer.sherif.001 on Jan 23, 2013
Latest reply on May 4, 2015 by suur.peeter
Hi guys,

I'm using two channels of ADC1 to convert two different inputs, i'm using the interrupt mode of End Of Conversion.

I don't know how to get these values into two different variables.

Please take a look at my code,

     /* Initialize the ADC1 according to the ADC_InitStructure members */
     ADC_InitTypeDef ADC_InitStructure;

     ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
     ADC_InitStructure.ADC_ScanConvMode = ENABLE; /* Choose ADC to scan all the channels registered */
     ADC_InitStructure.ADC_ContinuousConvMode = ENABLE; /* Choose Continuous mode, ADC starts another conversion as soon as it finishes one */
     ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None; /* Start conversion by software */
     ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
     ADC_InitStructure.ADC_NbrOfChannel = 2; /* ADC1_IN0 and ADC1_IN3 */
     ADC_Init(ADC1, &ADC_InitStructure);

     /* Configures ADC1 (Bat_Status) Channel0 as: first converted channel with a 7.5 cycles sample time */
     ADC_RegularChannelConfig(ADC1, ADC_Channel_0, 1, ADC_SampleTime_7Cycles5); //Sample time may need modification, Old=0.4us, New=0.375us

     /* Configures ADC1 (ADC) Channel3 as: second converted channel with a 7.5 cycles sample time */
     ADC_RegularChannelConfig(ADC1, ADC_Channel_3, 2, ADC_SampleTime_7Cycles5); //Sample time may need modification

     /* Enable ADC1 EOC interrupt */
     ADC_ITConfig(ADC1, ADC_IT_EOC, ENABLE); /* EOC = End Of Conversion */

     /* Enable ADC1 */
     ADC_Cmd(ADC1, ENABLE);

     /* Reset the ADC1 Calibration registers */

     /* Check the end of ADC1 reset calibration register */

     /* It is recommended to start calibration for the ADC after each power up */
     /* Start the ADC1 Calibration */

     /* Get the ADC1 calibration status */

     /* Start by software the ADC1 Conversion */
     ADC_SoftwareStartConvCmd(ADC1, ENABLE);

In the handler, i clear the interrupt bending bit then what? how to choose a specific channel to get it's value?

Any help would be so much appreciated