EasyManuals Logo

ST STM8S Reference Manual

ST STM8S
449 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 #415 background imageLoading...
Page #415 background image
RM0016 Analog/digital converter (ADC)
Doc ID 14587 Rev 8 415/449
24.5.3 Channel selection
There are up to 16 external input channels that can be selected through CH[0:3] bits of the
ADC_SR register. The number of external channels depends on the device (refer to the
product datasheets).
If the channel selection is changed during a conversion, the current conversion is reset and
a new start pulse is sent to the ADC.
24.5.4 Conversion modes
The ADC supports five conversion modes: single mode, continuous mode, buffered
continuous mode, single scan mode, continuous scan mode.
Note: ADC1 AIN12 channel cannot be selected in ADC scan mode or with analog watchdog.
Values converted from AIN12 are stored only in the ADC_DRH/ADC_DRL registers. Refer
to product datasheet for AIN12 availability.
Single mode
In Single conversion mode, the ADC does one conversion on the channel selected by the
CH[3:0] bits in the ADC_CSR register. This mode is started by setting the ADON bit in the
ADC_CR1 register, while the CONT bit is 0.
Once the conversion is complete, the converted data are stored in the ADC_DR register, the
EOC (End of Conversion) flag is set and an interrupt is generated if the EOCIE bit is set.
Continuous and buffered continuous modes
In continuous conversion mode, the ADC starts another conversion as soon as it finishes
one. This mode is started by setting the ADON bit in the ADC_CR1 register, while the CONT
bit is set.
If buffering is not enabled (DBUF bit = 0 in the ADC_CR3 register), the converted data
is stored in the ADC_DR register and the EOC (End of Conversion) flag is set. An
interrupt is generated if the EOCIE bit is set. Then a new conversion starts
automatically.
If buffering is enabled (DBUF bit =1) the data buffer is filled with the results of 8 or 10
consecutive conversions performed on a single channel. When the buffer is full, the
EOC (End of Conversion) flag is set and an interrupt is generated if the EOCIE bit is
set. Then a new set of 8 or 10 conversions starts automatically. The OVR flag is set if
one of the data buffer registers is overwritten before it has been read (see
Section 24.5.5).
To stop continuous conversion, reset the CONT bit to stop conversion or reset the ADON bit
to power off the ADC.
Single scan mode
This mode is used to convert a sequence of analog channels from AIN0 to AINn where ‘n’ is
the channel number defined by the CH[3:0] bits in the ADC_CSR register. During the scan
conversion sequence the CH[3:0] bits are updated by hardware and contain the channel
number currently being converted.
Single scan mode is started by setting the ADON bit while the SCAN bit is set and the
CONT bit is cleared.

Table of Contents

Other manuals for ST STM8S

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the ST STM8S and is the answer not in the manual?

ST STM8S Specifications

General IconGeneral
BrandST
ModelSTM8S
CategoryMicrocontrollers
LanguageEnglish

Related product manuals