AnsweredAssumed Answered

ADC1 single scan conversion problem

Question asked by pokorny.ondrej on Sep 16, 2014
Latest reply on Nov 10, 2017 by Clive One
Hello everybody,
when doing ADC1 single scan conversion (ADC0 to ADC2 channels) during the first run after reset the ADC2 is always 0 (ADC1 and 0 are OK). The next and following sets of readings are then all OK. It is tested on STM8S Discovery (STM8S105C6). Code:
"
    ADC_Config();
    ADC1_StartConversion();
    while( ADC1_GetFlagStatus(ADC1_FLAG_EOC) != RESET)
     ;
    HS_buffer[0] = ADC1_GetBufferValue(2);
    SU_buffer[0] = ADC1_GetBufferValue(1);
    U_steu = ADC1_GetBufferValue(0);
    ADC1_DeInit();
"
where ADC_config():
"
 ADC1_DeInit();/* De-Init ADC peripheral*/
  /* Init ADC2 peripheral */
 ADC1_ScanModeCmd(ENABLE);
 ADC1_Init(ADC1_CONVERSIONMODE_SINGLE, ADC1_CHANNEL_2, ADC1_PRESSEL_FCPU_D2, \
            ADC1_EXTTRIG_TIM, DISABLE, ADC1_ALIGN_RIGHT,\
      ADC1_SCHMITTTRIG_CHANNEL0 | ADC1_SCHMITTTRIG_CHANNEL1 | ADC1_SCHMITTTRIG_CHANNEL2,\
            DISABLE);
"
When I (during the problematic first run) set breakpoint on the
"HS_buffer[0] = ADC1_GetBufferValue(2);" and do step- the result is OK.

I solve it by dummy reading after reset, but I would like to know the reason.
Thank You.

Outcomes