2023-05-16 04:15 AM
void Init_ADC(void)
{
ADC1_DeInit();
ADC1_Init(ADC1_CONVERSIONMODE_CONTINUOUS, ADC1_CHANNEL_5, ADC1_PRESSEL_FCPU_D2,
ADC1_EXTTRIG_TIM, DISABLE, ADC1_ALIGN_RIGHT, ADC1_SCHMITTTRIG_CHANNEL5,DISABLE);
}
void ADC_Read(unsigned int MV)
{
ADC1_DeInit();
ADC1_Init(ADC1_CONVERSIONMODE_CONTINUOUS, ADC1_CHANNEL_5, ADC1_PRESSEL_FCPU_D2,
ADC1_EXTTRIG_TIM, DISABLE, ADC1_ALIGN_RIGHT, ADC1_SCHMITTTRIG_CHANNEL5,DISABLE);
ADC1_StartConversion();
MV=ADC1_GetConversionValue();
ADC1_Cmd(ENABLE);
while(ADC1_GetFlagStatus(ADC1_FLAG_EOC) == FALSE);
ADC1_ClearFlag(ADC1_FLAG_EOC);
ADC1_Cmd(DISABLE);
}
2023-05-16 04:32 AM
What value ARE you expecting?
And what voltage is it supposed to be measuring?
In the future perhaps use the code pasting window via the </> icon
2023-05-16 04:46 AM
Iam expecting the value as 760 and if power off less than that but I am getting a constant value for all when powered up and powered off .