cancel
Showing results for 
Search instead for 
Did you mean: 

ADC1 single scan conversion problem

pok-on
Associate II
Posted on September 16, 2014 at 11:21

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.

#stm8 #adc1 #single-scan
3 REPLIES 3
pok-on
Associate II
Posted on September 16, 2014 at 11:30

Of course,

there should be '' == RESET''. Now it works fine. Does anybody know, how to delete the thread? I think it is not really helpful :-).

Rita Jonkute
Associate II
Posted on November 10, 2017 at 13:01

Hello, could you share a full code?

Posted on November 10, 2017 at 16:44

This is a 3-year old thread, forum may not alert since it was moved to a different platform a year ago.

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