cancel
Showing results for 
Search instead for 
Did you mean: 

In stm8s0003f3 ,I am reading analog voltage.I am getting the value in watch as 1544,which is not expected .Can some one help what may be the fault in the code. supply vge is 1.8v

SRAM.11
Associate III

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);

}

2 REPLIES 2

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

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
SRAM.11
Associate III

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 .