Question
ADC channel reading
Posted on January 23, 2013 at 16:16
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 */ ADC_ResetCalibration(ADC1); /* Check the end of ADC1 reset calibration register */ while(ADC_GetResetCalibrationStatus(ADC1)); /* It is recommended to start calibration for the ADC after each power up */ /* Start the ADC1 Calibration */ ADC_StartCalibration(ADC1); /* Get the ADC1 calibration status */ while(ADC_GetCalibrationStatus(ADC1)); /* 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 #dma #adc #adc #stm32 #stm32