AnsweredAssumed Answered

STM8S105C4T6 Now work ! adc1 with scan mode

Question asked by Pol on Dec 8, 2014
Latest reply on Nov 10, 2017 by Rita Jonkute
After used a lot of time to read and find (and not found), now i have done the code after try it own.

And now, i want to share to you.

my project need to get analog input 5 channels from ch0 to ch4 with scan mode

that's i don't include all of code, you may consider for some line


1.   GPIO_Init(GPIOB,GPIO_PIN_ALL,GPIO_MODE_IN_FL_NO_IT);     // set IO mode on port B
2.   ADC1_DeInit();
3.   ADC1_DataBufferCmd(ENABLE);          // enable buffer
4.   ADC1_ScanModeCmd(ENABLE);          // enable scan mode
5.   ADC1_ITConfig(ADC1_IT_EOCIE,DISABLE);   // disable interrupt when using scan mode

// scan to channel that's need , this code is scan from ch0 to ch4
                    ADC1_EXTTRIG_TIM     ,DISABLE,ADC1_ALIGN_RIGHT,\
                    ADC1_SCHMITTTRIG_CHANNEL4  ,DISABLE);                      

7.   enableInterrupts();     

8.   ADC1_StartConversion(); 

9.   percent=ADC1_GetBufferValue(i);   // percent is u16 variable, i is channel want to get values

you can get the value in anytimes

hope this will help you