STM32------ADC

ADC

1. Introduction to ADC

1.1 Introduction

ADC is an analog-to-digital converter.

For example: electrical signals are converted into digital quantities.

1. 2 ADC type

Parallel comparison type, successive approximation type

The parallel comparison type is as follows:

Voltage dividing part + comparison part + encoding part.

ADC resolution: three bits (above)

Advantages: Fast conversion speed.

Disadvantages: high cost, high power consumption, low resolution.

The successive approximation type is as follows:

Control circuit + digital register + D/A converter + relatively strong voltage

Advantages: simple results, low power consumption.

Disadvantages: Slow conversion speed.

Features: Resolution and sampling speed are contradictory. The higher the resolution, the lower the sampling rate.

ADC characteristics

Resolution: scale division

For example: 3.3V 12-bit ADC

The scale is divided into 3.3/4096.

Conversion time: The shorter the time, the higher the sampling rate, and AD conversion takes time.

Accuracy: Accuracy is affected by ADC performance, temperature and air pressure.

Quantization error: The error caused by using digital quantities to approximately represent analog quantities and adopting the rounding principle.

2. ADC working principle

2.1 ADC block diagram

1. Reference voltage/analog part voltage

 

2. Input channel

16 outside the chip and 2 inside the chip, 18 in total.

3. Conversion sequence

 4. Trigger source

5. Conversion time

6. Data register

7. Interruption

2. 2 Reference voltage:

ADC power supply voltage: 2.4~3.6V

ADC input voltage range: 0~3.3V

2, 3 input channels

There are 3 ADCs and 16 channels are multiplexed by IO

2. 4 Conversion sequence

Rule group, injection group

The rules group has 16 transitions and the injection group has 4 transitions.

Execution priority comparison (injection group can interrupt rule group conversion):

Conversion sequence:

The rule sequence corresponds to the rule group conversion, and the corresponding registers are: SQR3 SQR2 SQR1

Inject sequence: JSQR

For example: convert two channels JL[1:0] to 1, the conversion sequence of the injected sequence starts from

 2.5 Trigger source

There are two ways to trigger a conversion:

1. ADON bit touch conversion (limited to F1)

When ADON in the ADC_CR register is 1, writing 1 to the ADON bit alone can only start rule group conversion.

2. External events trigger conversions

External event triggering conversion is divided into: rule group external triggering and injection group external triggering.

Trigger source:

How to use external triggering of rule groups:

2.6 Conversion time

1. How to set the ADC clock:

 How to set the ADC clock in the routine:

2. Set ADC conversion time

2.7 Data register

2.8 Interrupt

DMA request (applies only to rule groups)

After each channel of the rule group is converted, in addition to generating an interrupt, it can also generate a DMA request. We use DMA to transfer the converted data to the designated memory in a timely manner to prevent the data from being overwritten.

2. 9 Single conversion mode and continuous conversion mode

2. 10 scan mode

2.11 The role of different mode combinations

A less commonly used mode: discontinuous sampling mode (intermittent mode), only applicable in scan mode.

Guess you like

Origin blog.csdn.net/weixin_58125062/article/details/130665973