cancel
Showing results for 
Search instead for 
Did you mean: 

STM8S105C4T6 Now work ! adc1 with scan mode

ekpol
Associate II
Posted on December 08, 2014 at 05:05

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

code:

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

6.   ADC1_Init(ADC1_CONVERSIONMODE_CONTINUOUS,ADC1_CHANNEL_4,ADC1_PRESSEL_FCPU_D18,\

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

#stm8s-adc1-scan-mode
1 REPLY 1
Rita Jonkute
Associate II
Posted on November 10, 2017 at 11:27

Hi, 

could you please share a full code here?