EasyManuals Logo

STMicroelectronics STM8 User Manual

STMicroelectronics STM8
126 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #55 background imageLoading...
Page #55 background image
The second line of the above function states that we are going to use ADC channel 0 (PB0) with no
Schmitt trigger. We are also not going to use external triggers from timer/GPIO modules. Since the
master clock is running at 8MHz, the ADC prescaler divides the master/peripheral clock to get a
sampling frequency of 444kHz. We are also going to use continuous conversion mode because we
want to continually read the ADC input and don’t want to measure it in certain intervals. Lastly right-
justified data alignment is used as it is easy to read from such.
In the main loop, we need to start ADC conversion and wait for the conversion to complete. We are
not using interrupt methods and so we need to poll if ADC conversion has completed. At the end of
conversion, we can read the ADC and clear ADC End of Conversion (EOC) flag.
ADC1_StartConversion();
while(ADC1_GetFlagStatus(ADC1_FLAG_EOC) == FALSE);
A0 = ADC1_GetConversionValue();
ADC1_ClearFlag(ADC1_FLAG_EOC);
The rest of the code is about printing the ADC data on a LCD.
Demo
Video link: https://www.youtube.com/watch?v=rx68zPDEZUU

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the STMicroelectronics STM8 and is the answer not in the manual?

STMicroelectronics STM8 Specifications

General IconGeneral
BrandSTMicroelectronics
ModelSTM8
CategoryMicrocontrollers
LanguageEnglish

Related product manuals