I have formatted your code again and inserted it with the </> button under the text field:
ADC1_DeInit();
ADC1_Init(ADC1_CONVERSIONMODE_CONTINUOUS, ADC1_CHANNEL_2, ADC1_PRESSEL_FCPU_D2, ADC1_EXTTRIG_TIM, DISABLE, ADC1_ALIGN_RIGHT, ADC1_SCHMITTTRIG_CHANNEL2, DISABLE); // OCD
ADC1_Init(ADC1_CONVERSIONMODE_CONTINUOUS, ADC1_CHANNEL_3, ADC1_PRESSEL_FCPU_D2, ADC1_EXTTRIG_TIM, DISABLE, ADC1_ALIGN_RIGHT, ADC1_SCHMITTTRIG_CHANNEL3, DISABLE); // TEMP SENSOR
ADC1_Init(ADC1_CONVERSIONMODE_CONTINUOUS, ADC1_CHANNEL_4, ADC1_PRESSEL_FCPU_D2, ADC1_EXTTRIG_TIM, DISABLE, ADC1_ALIGN_RIGHT, ADC1_SCHMITTTRIG_CHANNEL4, DISABLE); //VBAT
ADC1_Init(ADC1_CONVERSIONMODE_CONTINUOUS, ADC1_CHANNEL_5, ADC1_PRESSEL_FCPU_D2, ADC1_EXTTRIG_TIM, DISABLE, ADC1_ALIGN_RIGHT, ADC1_SCHMITTTRIG_CHANNEL5, DISABLE); // MAINS VGE
ADC1_Cmd(ENABLE);
ADC1_StartConversion();
while(ADC1_GetFlagStatus(ADC1_FLAG_EOC) == FALSE);
ADC1_GetConversionValue();
ADC1_ClearFlag(ADC1_FLAG_EOC);
Well, you:
- configured the ADC four times (line 3...6),
- but only started it once (line 9)
- and then read the value without using it (line 12)
For the first measurement of OCD you should only use channel 2, so delete lines 4...6 and in the old line 12 assign the return value of ADC1_GetConversionValue(); to a variable, e.g. result_OCD, which you can then use further.
Then do the same with channels 3...5, of course with a different result variable each (e.g. result_TEMP_SENSOR, etc).
In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.