2014-09-16 02:21 AM
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-scan2014-09-16 02:30 AM
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 :-).2017-11-10 04:01 AM
Hello, could you share a full code?
2017-11-10 08:44 AM
This is a 3-year old thread, forum may not alert since it was moved to a different platform a year ago.