STM32 ADC principle

Publisher:算法之手Latest update time:2019-03-08 Source: eefocusKeywords:STM32  ADC Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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:


 


Keywords:STM32  ADC Reference address:STM32 ADC principle

Previous article:STM32 ADC single channel single routine
Next article:STM32 window watchdog routine

Recommended ReadingLatest update time:2024-11-16 11:40

All download methods about stm32
1. Download using ISP 1. When using isp to download, ensure that BOOT0=1, BOOT1=0, so that the system memory can be started (to avoid interruption of download by programs such as serial port output running in flash). The program started in this mode is downloaded through the serial port and downloaded using Flash Load
[Microcontroller]
51 microcontroller learning: ADC analog-to-digital conversion experiment-potentiometer voltage collection
Experiment name: ADC analog-to-digital conversion experiment - potentiometer voltage collection wiring instructions: Experimental phenomenon: After downloading the program, the digital tube displays the voltage value of the AD module collection potentiometer. Notes: *********** ****************************************
[Microcontroller]
Keil MDK3.20 debug stm32 method under ULINK
    1. Programs run in RAM     Key points: (1) Change the download address of the program to the RAM space     (2) Before debugging the program, set the SP and PC pointers to the Ram space.     Create a new project and select the specific model of STM32. I bought Wanli development board and selected stm32f103Vb.      
[Microcontroller]
Keil MDK3.20 debug stm32 method under ULINK
stm32 startup file selection
The low-capacity products refer to the STM32F101xx, STM32F102xx and STM32F103xx microcontrollers with Flash memory capacities between 16K and 32K bytes. The medium-capacity products refer to the STM32F101xx, STM32F102xx and STM32F103xx microcontrollers with Flash memory capacities between 64K and 128K bytes. The high-
[Microcontroller]
Do STM32 global variables occupy program storage space?
Whether global variables occupy the storage space of the final program, this question has actually been answered as early as when we learned C language. I vaguely remember that when I first learned C language, the book told us: Global automatic variables - stored in the read-write data segment Global static variable
[Microcontroller]
Do STM32 global variables occupy program storage space?
[MCU framework][bsp layer][nrf51822][nrf51422][nrf51802][bsp_adc] ADC configuration and use
Analog to Digital Converter (ADC) The 10 bit incremental Analog to Digital Converter (ADC) enables sampling of up to 8 external signals through a front-end multiplexer. The ADC has configurable input, reference prescaling, and sample resolution (8, 9, and 10 bit). Note: The ADC module uses the same analog inputs as
[Microcontroller]
STM32 flash read and write operations
1. Introduction to Flash   The programming operation of stm32 can be realized by reading and writing the flash inside stm32.   The built-in programmable Flash of stm32 is of great significance in many occasions. For example, its support for ICP (In Circuit Programming) allows developers to debug and develop stm32,
[Microcontroller]
STM32 LED light based on 3.5 library 2
The 3.5 library is here: http://www.51hei.com/mcu/2765.html #include "stm32f10x.h" /*********************************************************************** ************************************************************************/ GPIO_InitTypeDef GPIO_InitStructure; /**********************************************
[Microcontroller]
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

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号