Analog-to-Digital Converter (ADC)
ADC is a very important peripheral in any modern-day microcontroller. It is used to read analogue
outputs from sensors, sense voltage levels and so on. For example, we can use an ADC to read a LM35
temperature sensor. The voltage output from the sensor is proportional to temperature and so we
can use the voltage info to back-calculate temperature. STM8S003K3 has four ADC channels
associated with one ADC block. Other STM8 micros have more ADC channels and ADC blocks. The ADC
of STM8 micros is just as same as the ADCs of other micros. There are a few additional features. Shown
below is the block diagram of the STM8's ADC peripheral:
A few things must be noted before using the ADC. These enhance performance significantly:
•
Input impedance should be less than 10kΩ.
•
It is better to keep ADC clock within or less than 4MHz.
•
Schmitt triggers must be disabled.
•
Opamp-based input buffer and filter circuits are preferred if possible.
•
If the ADC has reference source pins, they should be connected to a precision reference source
like LM336. It is recommended to use a good LDO regulator chip otherwise.
•
Unused ADC pins should not be configured or disabled. This will reduce power consumption.
•
Rather taking single samples, ADC readings should be sampled at fixed regular intervals and
averaged to get rid of minute fluctuations in readings.
•
Right-justified data alignment should be used as it is most convenient to use.
•
PCB/wire tracks leading to ADC channels must be short to reduce interference effects.
Need help?
Do you have a question about the STM8 and is the answer not in the manual?
Questions and answers