- A few terms:
a) Resolution (LSB): It indicates the change in input analog voltage required for the output digital quantity to change by one adjacent digital number. It is defined as the full-scale voltage of the converter and 2 to the power of n, where n is the number of bits of the ADC.
b) Quantization error: The error caused by the discrete value (quantization) of the analog value by a finite number. Therefore, the quantization error is theoretically one unit resolution, i.e., plus or minus 12LSB.
c) Conversion accuracy: reflects the difference between the actual ADC module and the ideal ADC module in terms of quantization when performing analog-to-digital conversion.
d) Conversion time: refers to the time required for the ADC to complete an analog/digital conversion.
2. Structure:
3. Reference voltage generator:
a) Refers to the required reference signal, usually a voltage reference. The MSP430 ADC12 has a built-in reference power supply with 6 programmable options.
b) Analog multiplexer: When multiple analog signals are sampled and A/D converted, in order to share a conversion core, the analog multiplexer needs to connect the multiple analog signals in a time-sharing manner, sampling and converting one signal at a time.
c) MSP430 ADC12 is configured with 8 external channels and 4 internal channels. It can realize external 8-channel analog signal input through A0~A7. The 4 internal channels can use multiple reference voltages and the output of the internal temperature sensor as analog input signals to be converted.
d) 12-bit converter core with sample and hold function: The ADC12 core is a 12-bit analog-to-digital converter that can store the result in the converter memory. The core uses two programmable reference voltages (Vr+ and Vr-) to define the maximum and minimum values of the conversion. The formula is: Nadc = 4095 * (Vin - Vr) / (Vr+ -Vr)
e) Timing control circuit required for sampling and conversion: Provides various signals required for sampling and conversion: ADC12CLK conversion clock, SAMPCON sampling and conversion signal, SHT controlled sampling period, SHS controlled sampling trigger source selection, ADC12SSEL selected core clock source and AC12DIV selected division coefficient.
4. ADC12 register:
a) Conversion control register ADC12CTL0
i. ADC12SC sampling/conversion control bit: When ENC = 1, ISSH = 0 and SHP = 1, ADC12SC starts A/D conversion from 0 to 1. ADC12SC automatically resets after the A/D conversion is completed. When SHP = 0, ADC12SC maintains high-level sampling, and a conversion is started when ADC12SC is reset.
ii. ENC conversion enable bit: 0 is the initial state, A/D conversion cannot be started; 1 is the first conversion started by the rising edge of SAMPCON.
iii. ADC12TIVE conversion time overflow interrupt enable bit: 0: no conversion time overflow occurs, 1: conversion time overflow occurs.
iv. ADC12OVIE overflow interrupt enable bit: 0 means no overflow occurs, 1 means overflow occurs.
v. ADC12ON: ADC12 core control bit: 0 means turning off the ADC12 core, 1 means turning it on.
vi. REFON: Reference voltage control bit, 0 means the internal reference voltage generator is turned off, 1 means the internal reference voltage generator is turned on.
vii. 2.5V internal reference voltage voltage value selection bit: 0 for 1.5V, 1 for 2.5V.
viii. MSC multiple sampling/conversion bit: It is only valid when SHP = 1. 0 means that each conversion requires the rising edge of the SHI signal to trigger the sampling timer. 1 means that only the first conversion is triggered by the rising edge of the SHI signal. The subsequent sampling conversion will be performed immediately after the previous conversion is completed.
ix. SHT1/SHT0 sample-and-hold timer: defines the relationship between the conversion sampling timing and the sampling clock ADC12CLK stored in the conversion result registers ADC12MEM8_ADC12MEM15 and ADC12MEM0~ADC12MEM7. The sampling period is n times the ADC12CLK period multiplied by 4. N is 2 to the power of SHITx. [page]
b) Conversion control register ADC12CTL1
i. CSStartAdd conversion storage address bit, can define a single conversion address or the first address of a sequence conversion.
ii. SHS sampling input trigger source selection: 0 is ADC12SC, 1 is Timer_A.OUT1, 2 is Timer_B.OUT0, 3 is Timer_B.OUT1.
iii. SHP sampling signal (SAMPCON) selection control bit: 0 means the signal source comes from the sampling trigger input signal, 1 means the signal source comes from the sampling timer, and the sampling timer is triggered by the rising edge of the sampling input signal.
iv. ISSH sampling input signal direction control bit: 0 means the sampling input signal is input in the same direction, 1 means it is input in the opposite direction.
v. ADC12DIV: ADC12 clock source division factor is selected.
vi. ADC12SSEL ADC12 core clock source selection: 0 is ADC12 internal clock source ADC12OSC (default), 1 is ACLK, 2 is MCLK, and 3 is SMCLK.
vii. CONSEQ conversion mode selection bit: 0 is single-channel single conversion mode, 1 is sequential channel single conversion mode, 2 is sequential channel multiple conversion mode, and 3 is sequential channel multiple conversion mode.
viii. ADC12BUSY ADC12 busy flag: 0 means no activity, 1 means busy.
c) ADC12MEM0~ADC12MEM15 conversion storage register: 16-bit register used to store A/D conversion results, only the lower 12 bits are used.
d) ADC12MCTLx conversion memory control register:
i. EOS: Sequence end control bit: 0 means the sequence has not ended, 1 means it has ended.
ii. Sref reference voltage source selection bit:
iii. INCH selects the analog input channel: The 4-bit binary number represents the selected analog input channel:
e) ADC12IFG interrupt flag register: ADC12IFGx is set to indicate that the conversion is completed and the conversion result has been loaded into the conversion storage register; ADC12IFGx is reset to indicate that ADC12MEMx is accessed.
f) ADC12IE interrupt enable register: 1 allows the interrupt request service that occurs when the corresponding ADC12IFGx is set, and 0 prohibits the interrupt request service that occurs when ADC12IFGx is set.
g) ADC12IV interrupt vector register.
5. Initialization code
- /****************************************************** ************************
- // Name: ADC12Init
- //Parameter: uchar Times-0 is a single conversion, 1 is multiple conversions,
- uchar Tube-0 is single channel conversion, 1 is multi-channel conversion
- uchar n-channel to be converted (only useful when Tube is 0)
- uchar V-0 is the internal reference voltage, 1 is the external reference voltage
- //Return value: None
- //Function: Complete the initialization of ADC12Init
- *************************************************** *************************/
- void ADC12Init(uchar Times,uchar Tube,uchar n,unsigned char v)
- {
- if(Tube ==0) // Single channel conversion
- {
- if(v == 0)
- {
- ADC12CTL0 = ADC12ON + SHT0_8 + MSC + REFON + REF2_5V; //Use internal voltage, turn on ADC12 core, divide by 8, internal reference voltage 2.5V
- ADC12MCTL0 = SREF_0; //Use internal voltage, reference bits are AVCC and AVSS
- }
- if(v == 1)
- {
- ADC12CTL0 = ADC12ON + SHT0_8; //Use external voltage to turn on the ADC12 core and divide by 8
- ADC12MCTL0 = SREF_2; //Use external voltage, reference is VeREF+ and AVSS
- }
- if(Times == 0)ADC12CTL1 = SHP + CONSEQ_0; //Single channel single conversion, the sampling signal comes from the sampling timer
- if(Times == 1)ADC12CTL1 = SHP + CONSEQ_2; //Single channel multiple conversions, the sampling signal comes from the sampling timer
- switch (n) //Select channel
- {
- case 0:ADC12MCTL0 |= INCH_0;break;
- case 1:ADC12MCTL0 |= INCH_1;break;
- case 2:ADC12MCTL0 |= INCH_2;break;
- case 3:ADC12MCTL0 |= INCH_3;break;
- case 4:ADC12MCTL0 |= INCH_4;break;
- case 5:ADC12MCTL0 |= INCH_5;break;
- case 6:ADC12MCTL0 |= INCH_6;break;
- case 7:ADC12MCTL0 |= INCH_7;break;
- }
- ADC12IE = n; // Enable the interrupt of the channel to be converted
- ADC12CTL0 |= ENC; //Turn on software enable
- }
- if(Tube ==1) //Multi-channel conversion
- {
- if(v == 0)
- {
- ADC12CTL0 = ADC12ON + SHT0_8 + MSC + REFON + REF2_5V; //Use internal voltage, turn on ADC12 core, divide by 8, internal reference voltage 2.5V
- ADC12MCTL0 = SREF_0; //Use internal voltage, reference bits are AVCC and AVSS
- }
- if(v == 1)
- {
- ADC12CTL0 = ADC12ON + SHT0_8; //Use external voltage to turn on the ADC12 core and divide by 8
- ADC12MCTL0 = SREF_2; //Use external voltage, reference is VeREF+ and AVSS
- }
- if(Times == 0)ADC12CTL1 = SHP + CONSEQ_1; //Multi-channel single conversion, the sampling signal comes from the sampling timer
- if(Times == 1)ADC12CTL1 = SHP + CONSEQ_3; //Multi-channel multiple conversions, the sampling signal comes from the sampling timer
- ADC12IE = 0xff; // Enable the interrupt of the channel to be converted
- ADC12CTL0 |= ENC; //Turn on software enable
- }
- }
Previous article:ADC12 module of MSP430F149
Next article:MSP430 Learning Notes (3) Clock Module
- Popular Resources
- Popular amplifiers
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
- Principles and Applications of Single Chip Microcomputers 3rd Edition (Zhang Yigang)
- Principles and Applications of Single Chip Microcomputers and C51 Programming (3rd Edition) (Xie Weicheng, Yang Jiaguo)
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
- In AD, if the circle on the surface of the circuit board is not painted with green paint, should a solid circle or a ring be drawn on the TOPSOLDER layer?
- Regarding the question of whether the GND level is stable
- AD19 installation package always reports errors
- Tektronix offers free trials for more than 100 advanced application functions!
- Research on A-type digital flaw detection system based on FPGA.pdf
- Phase loss detection of three-phase three-wire circuit
- EEWORLD University Hall----Principle and Operation of DC Bridge Fudan University
- Small base stations can also take the center stage in the 5G era
- What is the packaging of integrated circuits? What are the common types of packaging? What are their respective characteristics?
- Vivado prompts [Synth 8-91] ambiguous clock in event control Problem Cause