Hi,I am working on STM8s0003f3.I need to read analog voltage from ADC_Channel_5 I have stuck at how to initialise channel cmd for the same as I dont find any ADC_Read examples.Can someone help me sort it out please
..
..
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:
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).
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.