STM8S special topic: ADC data conversion

Publisher:painterLatest update time:2021-09-24 Source: eefocusKeywords:STM8S Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Introduction

Digital signals are discrete signals, and analog signals are continuous signals. If a digital circuit needs to process an analog signal, a signal conversion system is required. Conversely, analog circuits also need to perform signal conversion to process digital signals.


The A/D and D/A converters are the bridges for processing the two signals.


Common A/D converters include parallel comparison type, successive approximation type, VF type, double integral type, etc.


Common D/A converters include weighted resistor network type, inverted T-type resistor network type, weighted capacitor network type, weighted current type, switch tree structure type, etc.


principle

system framework

Different STM8S microcontroller models have different ADC resources. Taking ADC2 as an example, ADC2 is a 10-bit successive approximation A/D converter that can provide 16 input channels.

The above figure is the structure diagram of A/D conversion, with signal input on the left, signal conversion in the middle, and signal output on the right. The core part is the intermediate signal conversion, with 3 configuration lines below.


ADON (ADC_CR1) is for power-on wake-up/conversion start. The first time it is set to 1, it wakes up the ADC. The second time it is set to 1, it starts the conversion. The second time it is set to 0, it shuts down the ADC.


CONT (ADC_CR1) is single/continuous conversion, set to 0 for single conversion, set to 1 for continuous conversion.


CH[3:0] (ADC_CSR) is the analog signal input channel selection, and the configuration value corresponds to AIN0~AIN15.


There are three trigger signals to start ADC conversion: software trigger (ADON), TIM1 timer trigger signal (TRGO), and external pin trigger (ADC_ETR).


The AD conversion related pins are described as follows:

Conversion Mode

The ADC1 advanced AD converter supports five conversion modes: single mode, continuous mode, continuous mode with buffer, single scan mode, and continuous scan mode.


ADC2 general AD converter supports single and continuous modes.


Single mode

Suitable for converting different channels one by one.


First, select the input channel, configure the CONT bit to 0, and the ADON bit to 1 to start the conversion. After the conversion is completed, the conversion end flag EOC (ADC_CSR) is set to 1, and the data is stored in the ADC data register. If the conversion end interrupt EOCIE (ADC_CSR) is enabled, an interrupt request is generated.


The ADC single conversion timing is as follows:

Continuous conversion


Suitable for continuous conversion of selected channels.

The ADC continuous conversion timing is as follows:

First, select the channel, set CONT to 1 to start the continuous conversion mode. After power-on, set ADON to 1 for the first time to wake up the conversion unit, delay for a period of time to stabilize the timing, set it to 1 again to start the conversion, and when the conversion is completed, EOC is set to 1. The data is cached in ADC_DR (need to be read in time, you can query EOC or interrupt reading). If the interrupt is enabled, a conversion end interrupt will be generated. Then the next conversion is automatically started. The EOC status bit needs to be cleared by software.


Conversion speed

The ADC conversion speed depends on the ADC clock frequency, which in turn depends on the system clock frequency and the ADC division factor. The division factor can be set using the SPSRL[2:0] (ADC_CR1) bits.

The ADC conversion requires 14 clock cycles, 3 samples, and 11 conversions.


Conversion accuracy

Taking ADC2 as an example, the resolution is 10 bits, and the analog channel input signal voltage is 5V, then the minimum voltage level is 5/2 times 10, and the resolution accuracy can reach 4.88mv. When the analog signal is higher than the IC reference voltage, a hardware voltage divider circuit needs to be designed.


register

Control Status Register ADC_CSR

Used for analog input channel selection, conversion end interrupt enable, and conversion end flag setting.

Control register 1ADC_CR1

Used for frequency division factor configuration, conversion mode configuration, power-on wake-up/conversion start configuration.

'

Control register 2ADC_CR2

External trigger mode configuration, trigger enable configuration, data alignment configuration

The data converted by ADC is 10 bits and needs two registers to store.

Left justified: the upper 8 bits are written to ADC_DRH and the remaining bits are written to ADC_DRL.

Right justified: the lower 8 bits are written to ADC_DRL and the remaining bits are written to ADC_DRH.


process

Keywords:STM8S Reference address:STM8S special topic: ADC data conversion

Previous article:Multi-channel continuous AD acquisition of STM8 microcontroller
Next article:STM8S special topic GPIO input and output

Recommended ReadingLatest update time:2024-11-16 17:39

PIC16F877_adc usage
  #include pic.h #define two RC0 #define   wei  RC1 __CONFIG (0X3B31); bit AD_FLAG; const char  dua_table = { 0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90 };   const char  ddua_table = { 0x40,0x79,0x24,0x30,0x19,0x12,0x02, 0x78,0x00,0x10 }; const char wei_arry = {0x01,0x02,0x04,0x08}; //bit selection encodin
[Microcontroller]
PIC16F877_adc usage
How to use STM8S MCU
Why use the STM8 series? When choosing a microcontroller for a project or product, it is imperative that you choose the right one. PIC devices are excellent due to their ongoing production and support from Microchip, while AVR devices contain a very powerful CPU (perhaps more CISC than RISC). However, a simple prototy
[Microcontroller]
How to use STM8S MCU
ADC multi-channel acquisition program for STM32f103 digital electrical acquisition circuit
STM32 has 1~3 ADCs (STM32F101/102 series has only 1 ADC), which can be used independently or in dual mode (increasing the sampling rate). The ADC of STM32 is a 12-bit successive approximation analog-to-digital converter. It has 18 channels and can measure 16 external and 2 internal signal sources. The A/D conversion o
[Microcontroller]
ADC multi-channel acquisition program for STM32f103 digital electrical acquisition circuit
STM8S---Timer generates PWM (TIM2)
1 Description Use STM8S internal clock (HSI); PWM mode 2; The duty cycle is 50% and the frequency is 2Hz (convenient for testing LED lights); PD2 port is connected to an external LED light, and PD2 port outputs PWM wave; System clock initialization is very important: CLK_CKDIVR |= 0x08; 2 Code /* TIM2_CH3 PWM
[Microcontroller]
STM8 Analog/Digital Converter (ADC) conversion modes
STM8 analog/digital converter (ADC) conversion mode The ADC supports five conversion modes: single mode, continuous mode, continuous mode with buffer, single scan mode, and continuous scan mode. Single mode In the ADC single conversion mode of STM8, the ADC completes only one conversion on the channel selected by CH
[Microcontroller]
Why does a forehead thermometer require a high-precision Sigma-Delta ADC?
Due to the impact of the epidemic, infrared temperature measurement guns are in short supply and a hot topic of concern to electronic engineers. Before the epidemic, there was basically only one mainstream solution for forehead temperature guns, which generally used an analog front end of Sigma-delta ADC with effectiv
[Mobile phone portable]
Why does a forehead thermometer require a high-precision Sigma-Delta ADC?
stm8s timing interrupt
The stm8s timer has advanced timer TIM1, general timer TIM2, TIM3, TIM5, and basic timer TIM4, TIM6. The timer interrupt configuration is basically the same. What needs to be noted is that the frequency division is different and the number of timer bits is different. The configuration of the 16-bit timer will be discu
[Microcontroller]
Design and implementation of communication between multi-channel synchronous sampling ADC (AD7606) and floating-point DSP (ADSP-21479) in power system
. Introduction 1.1 Introduction to AD7606 AD7606 is a 16-bit, 8-channel synchronous sampling analog-to-digital data acquisition system. AD7606 fully meets the requirements of the power system and has flexible digital filters, 2.5V reference voltage source, reference voltage buffer, and high-speed serial and para
[Embedded]
Design and implementation of communication between multi-channel synchronous sampling ADC (AD7606) and floating-point DSP (ADSP-21479) in power system
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components
Guess you like

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号