AN0021: Analog To Digital Converter - Silicon Labs

2y ago
86 Views
3 Downloads
476.70 KB
44 Pages
Last View : 17d ago
Last Download : 3m ago
Upload by : Kairi Hasson
Transcription

AN0021: Analog to Digital Converter(ADC)This application note describes how to use the Analog to DigitalConverter (ADC) of EFM32 Gecko Series 0 and 1 devices to convert an analog input voltage to a digital value. Many aspects ofthe ADC, including inputs, references, and the different operatingmodes are described. Calibration routines for offset and gain arealso included.The provided software examples show how to use the different operating modes of theADC. The example projects are configured for the EFM32 Gecko Series 0 and 1 devices, but can easily be ported to other EZR32 Wireless MCU and EFR32 WirelessGecko devices by changing the project settings.For simplicity, EFM32 Wonder Gecko, Gecko, Giant Gecko, Leopard Gecko, TinyGecko, Zero Gecko, and Happy Gecko are a part of the EFM32 Gecko Series 0.KEY POINTS There are new ADC features in EFM32Gecko Series 1 devices. This document discusses ADC operationand advanced features. The ADC supports offset and gaincalibration. This application note includes: This PDF document Source files Example C-code Multiple IDE projectsEZR32 Wonder Gecko, Leopard Gecko, and Happy Gecko are a part of the EZR32Wireless MCU Series 0.EFM32 Pearl Gecko and Jade Gecko (and future devices) are a part of the EFM32Gecko Series 1.EFR32 Blue Gecko, Flex Gecko, and Mighty Gecko are a part of the EFR32 WirelessGecko Series 1. ADC-silabs.com Smart. Connected. Energy-friendly.0101110.Rev. 1.11

AN0021: Analog to Digital Converter (ADC)Analog to Digital Converter1. Analog to Digital Converter1.1 IntroductionThe EFM32 Gecko ADC is a Successive Approximation Register (SAR) architecture. The maximum resolution is 12 bits, which canachieve one million samples per second (Msps). The integrated input MUX can select the ADC input from external pins or internal signals. With PRS and DMA, the ADC can operate without CPU intervention, minimizing current consumption or allowing the core to doother work. The ADC can be clocked at different speeds and run using different warm-up modes to reduce the energy consumptioneven further.This application note discusses general operation and usage of the ADC. In addition, advanced features and power saving techniquesare described. Software examples of ADC operation both with DMA and PRS are included. Offset and Gain Calibration of the ADC isalso described and included in the software examples.For extremely low power periodic ADC sampling, a software example that enters Energy Mode 2 (EM2) between each ADC sample isalso included. This is the best way to do low power ADC sampling for sampling frequencies below a couple of kHz.silabs.com Smart. Connected. Energy-friendly.Rev. 1.11 1

AN0021: Analog to Digital Converter (ADC)Analog to Digital Converter1.2 OverviewThe Figure 1.1 ADC Overview of EFM32 Giant Gecko on page 2 and Figure 1.2 ADC Overview of EFM32 Pearl Gecko on page 3illustrate the internal connections of the inputs, reference selection, and registers.ADCn CTRLADCn SINGLEDATAADCn CMDADCn SCANDATAADCn SINGLECTRLADCn STATUSHFPERCLKADCnPrescalerADC CLKADCn CH0ADCn CH1ADCn CH2ADCn CH3ADCn CH4ADCn CH5ADCn CH6ADCn CH7ADCn trol SARTempVDD/3VDDVSSVref/2DAC0DAC1-VDD1.25 V2.5 V5 V differential2x(VDD-VSS)Figure 1.1. ADC Overview of EFM32 Giant Geckosilabs.com Smart. Connected. Energy-friendly.Rev. 1.11 2

AN0021: Analog to Digital Converter (ADC)Analog to Digital ConverterADCn BIASPROGADCn CMPTHRADCn CTRLADCn CMDADCn SINGLECTRLADCn SINGLECTRLXADCn STATUSADCn SINGLEDATAADCn SCANCTRLADCn SCANDATASCANINPUTIDADCn SCANCTRLXADCCLKMODEHFPERCLKADCnADC CLKPrescalerASYNCCLKADCnConversion clock(adc clk sar)SequencerSINGLESAMPLEFIFOSCAN SAMPLEFIFOADC OUT1AVDDDVDDDECOUPLEIOVDDvdd muxTEMPINP MUXControlOversamplingfilter-VSSINN MUXAPORT1YAPORT2YAPORT3YAPORT4Y APORT0YVSSADCn EXTPADCn EXTNFigure 1.2. ADC Overview of EFM32 Pearl GeckoSome new ADC features (see the list below) are added in the EFM32 Gecko Series 1 and EFR32 Wireless Gecko Series 1 devices. Externally controllable conversion start time using PRS in TIMED modeCan be run during EM2 and EM3, waking up the system upon various enabled interruptsCan be run during EM2 and EM3 with DMA enabled to pull data from the FIFOs without waking up the systemAutomated clock gating to save power when not convertingSupports up to 144 external input channels and 11 internal inputs Includes temperature sensor and random number generator functionProgrammable scan sequence Up to 32 configurable samples in scan sequence Four deep FIFOs to store conversion data along with a channel ID and an option to overwrite old data when full Programmable watermark (DVL) to generate a SCAN interrupt Supports window compare functionProgrammable single-channel conversion Four deep FIFOs to store conversion data along with an option to overwrite old data when full Programmable watermark (DVL) to generate a SINGLE interrupt Supports window compare functionProgrammable and preset input full scale (peak-to-peak) range (VFS) with selectable reference sources User-programmable dividers for flexible VFS options from internal, external, or supply voltage reference sourcesInterrupt generation and/or a DMA request when Programmable number of converted data available in the single FIFO (also generates DMA request)silabs.com Smart. Connected. Energy-friendly.Rev. 1.11 3

AN0021: Analog to Digital Converter (ADC)Analog to Digital Converter Programmable number of converted data available in the scan FIFO (also generates DMA request)Single FIFO overflow or underflowScan FIFO overflow or underflowLatest Single conversion tripped compare logicLatest Scan conversion tripped compare logicAnalog over-voltage interruptProgramming Error interrupt due to APORT Bus Request conflict or NEGSEL programming errorsilabs.com Smart. Connected. Energy-friendly.Rev. 1.11 4

AN0021: Analog to Digital Converter (ADC)General Operation2. General Operation2.1 Clock SelectionThe ADC has an internal pre-scaler which can divide the selected ADC conversion clock source. Any factor between 1 and 128 can bechosen by writing a value between 0 and 127 to the PRESC bit field in the ADCn CTRL register.The symbols for different clock sources can be found in Figure 1.1 ADC Overview of EFM32 Giant Gecko on page 2 and Figure1.2 ADC Overview of EFM32 Pearl Gecko on page 3.Table 2.1. ADC Clock SelectionItemEFM32 Gecko Series 0 and EZR32Series 0EFM32 Gecko Series 1 and EFR32 WirelessGecko Series 1ADC peripheral clock source (register interface)HFPERCLKHFPERCLKADC conversion clock sourceHFPERCLKThe ADC CLK is selected by ADCCLKMODE bitfield in the ADCn CTRL register HFPERCLK (ADCCLKMODE 0) ASYNCCLK (ADCCLKMODE 1)ASYNCCLK source—Selected by ADC0CLKSEL bit field in theCMU ADCCTRL register Disabled (ADC0CLKSEL 0) AUXHFRCO (ADC0CLKSEL 1) HFXO (ADC0CLKSEL 2) HFSRCCLK (ADC0CLKSEL 3)ADC conversion clock frequencyADC CLK HFPERCLK / (1 to 128)Range is from 32 kHz to 13 MHzadc clk sar ADC CLK / (1 to 128)Range is from 32 kHz to 16 MHzClock source for ADC operation in EM2and EM3—AUXHFRCO (ASYNCCLK) is the only availableoption during EM2 or EM32.2 Input SelectionThe external inputs can either be selected as single-ended inputs or combined to allow for differential inputs (see 3.6 Analog Port(APORT) for ADC). The DIFF bit field in the ADCn SINGLECTRL or ADCn SCANCTRL register enables differential mode.The ADC input signals are shielded fairly well against other noisy signals within the EFM32 Gecko. If high ADC accuracy is needed, it isadvisable not to use any of the unused ADC input pins for noise-inducing activities, such as serial communication.2.2.1 Single-Ended ModeIn single-ended mode the input signal is measured with ground as the negative input. The voltage span between 0 V and the selectedreference is divided in small steps according to the selected resolution.The result is an unsigned number between 0 and 2resolution - 1, indicating where the input voltage is located in the span between groundand the reference voltage.silabs.com Smart. Connected. Energy-friendly.Rev. 1.11 5

AN0021: Analog to Digital Converter (ADC)General Operation2.2.2 Differential ModeIn differential mode the measured value is the difference between two inputs. Since one input is defined as the positive input and theother is defined as the negative input, the difference can be positive or negative depending on which input is higher. As a result, theconversion result is a signed number represented in two's complement form. If the negative input is higher than the positive input, theconverted value is negative (see 4.3 Differential Inputs and 5.3 Single and Scan Conversion with Differential Inputs). Note that the ADCcannot convert negative voltages in reference to ground.Table 2.2. ADC Input SelectionItemEFM32 Gecko Series 0 and EZR32 Series 0EFM32 Gecko Series 1 and EFR32 WirelessGecko Series 1External inputs for SingleEnded modeUp to 8, fix on pins PD0 – PD7Up to 144 through APORTExternal inputs for Differential Up to 8, fix on pins PD0 – PD7mode Two neighboring inputs are used in differentialmode, for instance channel 0 and channel 1 isone differential pair, channel 2 and channel 3another The lowest channel number is the positive differential inputUp to 72 through APORTInternal inputs6Up to 11Input filteringLow pass RC filter or an internal decoupling capacitor—Temperature sensorSet INPUTSEL bit field in the ADCn SINGLECTRL register to TEMPSet POSSEL bit field in the ADCn SINGLECTRLregister to TEMPOffset calibrationSet INPUTSEL bit field in the ADCn SINGLECTRL register to DIFF0 (short between positive and negative inputs)Set POSSEL and NEGSEL bit fields in theADCn SINGLECTRL register to VSSsilabs.com Smart. Connected. Energy-friendly.Rev. 1.11 6

AN0021: Analog to Digital Converter (ADC)General Operation2.3 Reference SelectionTo convert an analog voltage to a digital value, the ADC needs a reference voltage to which it compares the incoming analog voltage.Since the ADC cannot measure voltages larger than the reference voltage, the reference voltage should be above the maximum expected measured voltage.The selected reference source is combined with internal circuitry to produce the full-scale voltage (VFS) for the converter. VFS is thefull input range of the converter, from the lowest possible input voltage to the highest. For single-ended conversions, the input range onthe selected positive input is from 0 to VFS. For differential conversions, the input to the converter is the difference between the positiveand negative input selections. The ADC conversion result ranges from -VFS/2 to VFS/2.The maximum and minimum input voltage which the ADC can recognize at any external pin is limited to the supply voltages. If VFS isconfigured to be larger than the supply range (for example, VFS configured to 5 V when operating on a 3.3 V supply), the full ADCrange is not available.The ADC cannot measure negative voltages or voltages larger than the reference voltage. As a result, it is important to keep both inputs within the electrical limits of the device.Table 2.3. ADC Reference SelectionItemEFM32 Gecko Series 0 and EZR32 Series 0EFM32 Gecko Series 1 and EFR32 WirelessGecko Series 1Internal bandgap reference 1.25 V 2.5 V (supply voltage 2.5 V) 5 V differential (supply voltage 2.75 V) 1.25 V 2.5 V 5 V differentialInternal reference VDD Unbuffered 2 x VDD AVDD 2 x AVDDExternal single-ended referenceExternal differential referenceGPBIASACC bit field of theADCn BIASPROG registerPin PD6 as input Use pin PD6 as positive input Use pin PD7 as negative input Reference 2 x (PD6 – PD7)—silabs.com Smart. Connected. Energy-friendly.Use ADCn EXTP pin as input Use ADCn EXTP pin as positive input Use ADCn EXTN pin as negative input Reference 2 x (ADCn EXTP – ADCn EXTN) Set to 0 (HIGHACC) when an internal bandgapreference source is used Set to 1 (LOWACC) when AVDD or an externalpin reference is usedRev. 1.11 7

AN0021: Analog to Digital Converter (ADC)General Operation2.4 ConversionsA conversion consists of acquisition and approximation phases. The input is sampled in the acquisition phase before it is converted todigital representation during the approximation phase. The acquisition time can be configured independently for scan sequence andsingle channel conversions by setting AT bit field in the ADCn SINGLECTRL or ADCn SCANCTRL register.The symbols for different clock sources can be found in Figure 1.1 ADC Overview of EFM32 Giant Gecko on page 2 and Figure1.2 ADC Overview of EFM32 Pearl Gecko on page 3.Table 2.4. ADC ConversionsItemEFM32 Gecko Series 0 and EZR32 Series 0EFM32 Gecko Series 1 and EFR32 WirelessGecko Series 1ADC CLKPre-scaled HFPERCLKHFPERCLK or ASYNCCLKadc clk sar—Pre-scaled ADC CLKAcquisition time (AT)1 to 256 (integer power of 2) ADC CLK cycles1 to 256 (integer power of 2) adc clk sar cyclesMinimum acquisition time forVDD/32 µs—Minimum acquisition time for2 µsthe internal temperature sensorAT bit field of the ADCn SINGLECTRL orADCn SCANCTRL register should be set to avalue of 9 (256 adc clk sar cycles)ADC warm-up timeBased on HFPERCLKBased on ADC CLKADC total conversion time peroutput Tacq equals the number ofacquisition cycles N is the resolution in bits OVSRSEL is the oversampling ratio when oversampling is enabledIn ADC CLK cyclesIn adc clk sar cyclesTconv (Tacq N) x OVSRSELTconv (Tacq (N 1)) x OVSRSEL2.5 ADC ModesThe ADC contains two separate programmable modes: single channel mode and scan mode. Both modes have separate configurationand result registers. Both modes may be set up to run only once per trigger or to automatically repeat after each operation. The scanmode has priority over single channel mode.silabs.com Smart. Connected. Energy-friendly.Rev. 1.11 8

AN0021: Analog to Digital Converter (ADC)General Operation2.5.1 Single Channel ModeIn single channel mode, the ADC converts one input either one time or continuously if the REP bit field in the ADCn SINGLECTRLregister is set (see 4.1 Single Conversion and 5.1 Single and Scan Conversion). The DIFF bit field in the ADCn SINGLECTRL registerselects whether differential or single-ended inputs are used.Table 2.5. ADC Single Channel ModeItemEFM32 Gecko Series 0 and EZR32 Series 0EFM32 Gecko Series 1 and EFR32 WirelessGecko Series 1Input selectionThe input for single conversion is defined by thebit field INPUTSEL in the ADCn SINGLECTRLregisterThe POSSEL and NEGSEL bit fields in theADCn SINGLECTRL register select the input signalsFIFO for conversion results—4 x 32 bitProgrammable FIFO watermark (DVL) to generate SINGLE interrupt—The DVL bit field of the ADCn SINGLECTRLXregister controls the FIFO watermark crossingwhich sets the SINGLEDV bit in the ADCn STATUS registerSINGLEDV bit in theADCn STATUS register is setValid data in the ADCn SINGLEDATA register(DVL 1) number of single channel conversion results are available in single FIFOSINGLEOF bit in ADCn IF reg- Result is not read before the next result is ready, Signals that a result from a single channel FIFOister is setthe first result is overwrittenhas been overwritten before being readADCn SINGLEFIFOCOUNTregister—Number of unread data available in single FIFOADCn SINGLEFIFOCLEARregister—Clear single FIFO contentsilabs.com Smart. Connected. Energy-friendly.Rev. 1.11 9

AN0021: Analog to Digital Converter (ADC)General Operation2.5.2 Scan ModeIn scan mode, the ADC can be configured to convert a sequence of different inputs, either one time or continuously if the REP bit fieldin the ADCn SCANCTRL register is set (see 4.2 Scan Conversion with DMA Transfer and 5.1 Single and Scan Conversion). The DIFFbit field in the ADCn SCANCTRL register selects whether differential or single-ended inputs are used. DMA can be used to transferresults to RAM after each conversion. All the results can then be read from RAM after the sequence has finished.Table 2.6. ADC Scan ModeItemEFM32 Gecko Series 0 and EZR32 Series 0EFM32 Gecko Series 1 and EFR32 Wireless Gecko Series 1Input selectionThe inputs included in the scan sequence aredefined by the bit field INPUTMASK inADCn SCANCTRL registerThe inputs included in the scan sequenceare defined by the ADCn SCANMASK,ADCn SCANINPUTSEL andADCn SCANNEGSEL registersFIFO for conversion results—4 x 32 bitProgrammable FIFO watermark (DVL) —to generate SCAN interruptThe DVL field of the ADCn SCANCTRLXregister controls the FIFO watermark crossing which sets the SCANDV bit in theADCn STATUS registerSCANDV bit in the ADCn STATUSregister is setValid data in the ADCn SCANDATA register(DVL 1) number of scan conversion resultsare available in scan FIFOSCANOF bit in ADCn IF register issetResult is not read before the next result is ready, Signals that a result from a scan FIFO hasthe first result is overwrittenbeen overwritten before being readADCn SCANDATAX register—The FIFO data is tagged with SCANINPUTID and can be read along with the scandata using this registerADCn SCANFIFOCOUNT register—Number of unread data available in scanFIFOADCn SCANFIFOCLEAR register—Clear scan FIFO contentsilabs.com Smart. Connected. Energy-friendly.Rev. 1.11 10

AN0021: Analog to Digital Converter (ADC)General Operation2.6 Warm-Up ModesAfter power-on, the ADC requires some time for internal bias currents and references to settle prior to starting a conversion. This timeperiod is called the warm-up time and is performed by hardware. Firmware must program the number of clock cycles required to countat least 1 µs in the TIMEBASE bit field of the ADCn CTRL register.Normally, the ADC is warmed up only when samples are requested and is shut off when there are no more samples waiting. However,if lower latency is needed, configuring the WARMUPMODE bit field in the ADCn CTRL allows the ADC and/or reference to stay warmbetween samples, reducing the warm-up time or eliminating it altogether. Note that keeping the ADC and/or reference enabled betweensamples increases the energy consumption of the ADC.Note: Only the reference selected for scan mode is kept warm. To avoid warm-up time in single conversion mode, the single conversion reference needs to be the same as the scan conversion reference.Table 2.7. ADC Warm-up Mode of EFM32 Gecko Series 0Warmup ModeEFM32 Gecko Series 0 and EZR32 Series 0NORMAL ADC and references are shut off when there are no samples waiting When entering Energy Mode 2 or 3, the ADC must be stopped and WARMUPMODE must be setto NORMAL Total time Bandgap reference warm-up time (5 µs) ADC warm-up time (1 µs) ADC conversion timeFASTBG Bandgap warm-up is eliminated, but with reduced reference accuracy Total time ADC warm-up time (1 µs) ADC conversion timeKEEPSCANREFWARM The reference selected for scan mode is kept warm. The ADC will still need to be warmed upbefore conversion Total time ADC warm-up time (1 µs) ADC conversion timeKEEPADCWARM The ADC and the reference selected for scan mode are kept warm Total time ADC conversion timeTable 2.8. ADC Warm-up Mode of EFM32 Gecko Series 1Warmup ModeEFM32 Gecko Series 0 and EZR32 Series 1NORMAL ADC and references are shut off when there are no samples waiting Total time ADC warm-up time (5 µs) ADC conversion timeKEEPINSTANDBY The reference selected for scan mode is kept warm, but the ADC is powered down The ADC will initiate a 1 us warm-up period before a conversion begins Total time ADC warm-up time (1 µs) ADC conversion timeKEEPINSLOWACC It is similar to KEEPINSTANDBY, but continuously tracks the input, keeping the input multiplexerconnected to the analog bus Total time ADC warm-up time (1 µs) ADC conversion timeKEEPADCWARM The ADC and the reference selected for scan mode are kept warm Total time ADC conversion timesilabs.com Smart. Connected. Energy-friendly.Rev. 1.11 11

AN0021: Analo

AN0021: Analog to Digital Converter (ADC) This application note describes how to use the Analog to Digital Converter (ADC) of EFM32 Gecko Series 0 and 1 devices to con-vert an analog input voltage to a digital value. Many aspects of . Automated clock gating to save power when not convertingFile Size: 470KB

Related Documents:

Getting analog inputs to digital form D/A conversion “digital to analog” Getting digital inputs to analog form Digital I/O Sometimes you can fake analog values with digital (e.g., digital pulsing) 8 D/A Conversion “DAC” “D/A Converter” “Digital To Analog Converter

What is a Digital Analog Converter? Introduction In electronics, a digital-to-analog converter (DAC or D-to-A) is a device for converting a digital (usually binary) code to an analog signal (current, voltage or electric charge). An analog-to-digital converter (ADC) performs the

Converter (ADC) and Digital-to-Analog Converter (DAC). 1.2.2. Analog-to-Digital Converter (ADC) The transducer’s electrical analog output serves as the analog input to the ADC. The ADC converts this analog input to a digital output. This digital output consists of a number of bits that

Analog-to-Digital Converter (ADC) The TMS320x2833x ADC module is a 12-bit pipelined analog-to-digital converter (ADC). The analog circuits of this converter, referred to as the core in this document, include the front-end analog multiplexers (MUXs), sample-and-hold (S/H) circuits,

Figure 6. Three-bit, Flash Type Analog to Digital Converter Circuit Analog to Digital Converter (ADC): When selecting an Analog to Digital converter (ADC) chip for an application, three characteristics must be considered. Similar t

II. Evolution of the Analog RF-Digital Interface The analog RF-digital interface is significantly affected by the placement of the analog-to-digital converter (ADC)/digital-to-analog converter (DAC) pair. For most of the wireless systems designed in the 1990s, the ADC/ DACs we

There are mainly four types dc-dc converters: buck converter, boost converter, buck-boost converter, and flyback converter. The function of buck converter is to step down the input voltage. The function of boost converter, on the other hand, is to step up the input voltage. The function of buck-boost combines the functions of both buck converter

Plays are sometimes written from scratch; others are well known. KS3 Dramatic Society Club . of those students currently studying for ABRSM theory exams. Bring your lunch and have a chat. School Choir Large mixed (male and female voices) choir open to all years and abilities, which prepares for major musical events. Senior Jazz Combo Wild and unpredictable band of senior musicians in years .