The number of ADC bits determines the accuracy of ADC, which can be 8-bit, 12-bit, 16-bit, etc.
Another very important parameter is the conversion time.
ST M32f103RBT6 has 2 ADC controllers . 128KFlash, 20KRAM
Each ADC controller has multiple channels. For example, ADC1 has 16 external channels. It can be understood that there is a switch connecting each channel.
The sampling interval and sampling time of each channel can be set.
3. ADC channels and IO pin correspondence table
Generally, the negative reference voltage is connected to ground and the positive reference voltage is connected to 3.3V .
The analog input voltage cannot exceed 3.3V, otherwise the input pin may be burned.
ADC Block Diagram
Vref+ is connected to VDDA and Vref- is connected to VSSA.
A maximum of 4 channels are connected to the injection channel and a maximum of 16 channels are connected to the regular channel.
What is a regular channel: Equivalent to a normally running program, up to 16 channels, the regular channel and its conversion order are selected in ADC_SQRx, and the total number of regular group conversions should be written to L[3:0] of the ADC_SQR1 register .
The result of rule channel conversion is saved in the rule channel.
What is an injection channel: Equivalent to an interrupt, with a maximum of 4 injection channels. The injection group and its conversion order are selected in the ADC_JSQR register, and the total number of conversions in the injection group should be written to L[1:0] of the ADC_JSQR register.
The result of the injection channel conversion is saved in the data register of the injection channel.
Regular Channel VS Injection Channel
4. Single Conversion vs Continuous Conversion
After a single conversion is completed, it will not automatically switch to the conversion of another channel. Manual setting is required to start it. Continuous conversion means that another conversion will be automatically started immediately after the ADC conversion is completed.
Scan Mode
An EOC or JEOC interrupt is generated only after the last channel has been converted. Data is usually read via DMA.
5. ADC Interrupt
6. ADC clock configuration
For example: if the system clock is 72M, you need to choose 6-division or 8-division, and 6-division is 12M.
7. ADC_CR1 Register
Here we generally choose independent mode.
8. ADC_CR2 Register
IX. Alignment
Because STM32 is 12-bit AD and the register is 16 bits, you need to select the alignment method.
The software conversion selected in this experiment is that the 19:17 bits are set to 111.
10. ADC_SMPR1 Register
11. ADC_SMPR2 Register
The ADC clock has been set by the RCC_CFGR register.
The ADC_SMPR1 and ADC_SMPR2 registers are used to set the sampling time of channels 0 to 17. The sampling time of each ADC channel can be set independently.
Note: The minimum conversion time should be 1us
The minimum conversion time is 1us.
12. ADC_SQR1, SQR2, SQR3 regular sequence registers
Set the length of the regular channel sequence, which channel the first conversion corresponds to, which channel the second conversion corresponds to, and so on.
13. ADC_JSQR injection series register
14. ADC_DR Regular Channel Data Register
We mainly use the lower 16 bits here.
15. ADC_SR Status Register
16. Commonly used library functions for ADC
example:
Previous article:STM32 ADC single channel single routine
Next article:STM32 window watchdog routine
Recommended ReadingLatest update time:2024-11-16 11:40
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Repair a weird HC-SR04
- Request a free ZVS buck-boost evaluation board!
- bq30z50/55 senc file export configuration process
- Three-cell lithium battery charging management IC-VAS5176 charging current test
- USB TYPE C interface problem urgent help
- Notice on the extension of ON Semiconductor and Avnet IoT Innovation Design Competition
- Can't find header file when compiling
- RTC timekeeping function + GPIO control LCD12864 display
- On-chip memory resources of RSL10
- UART Protocol Timing Summary