Skip to main content
Associate III
May 16, 2023
Question

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

  • May 16, 2023
  • 2 replies
  • 1311 views

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

}

    This topic has been closed for replies.

    2 replies

    Tesla DeLorean
    Guru
    May 16, 2023

    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 VenmoUp vote any posts that you find helpful, it shows what's working..
    SRAM.11Author
    Associate III
    May 16, 2023

    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 .