Hexadecimal Notation. Least Significant Bit. Most Significant Bit. Analog-to-Digital. Digital-to-Analog. Sampling and Hold. Differential Non Linearity

Similar documents
8-bit RISC Microcontroller. Application Note. AVR182: Zero Cross Detector

8-bit Microcontroller. Application Note. AVR400: Low Cost A/D Converter

8-bit Microcontroller. Application Note. AVR222: 8-point Moving Average Filter

How to Calculate the Capacitor of the Reset Input of a C51 Microcontroller 80C51. Application Note. Microcontrollers. Introduction

8-bit RISC Microcontroller. Application Note. AVR236: CRC Check of Program Memory

8-bit Microcontroller. Application Note. AVR415: RC5 IR Remote Control Transmitter. Features. Introduction. Figure 1.

AT91 ARM Thumb Microcontrollers. Application Note. Interfacing a PC Card to an AT91RM9200-DK. Introduction. Hardware Interface

AVR305: Half Duplex Compact Software UART. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR120: Characterization and Calibration of the ADC on an AVR. 8-bit Microcontrollers. Application Note. Features. Introduction

Tag Tuning/RFID. Application Note. Tag Tuning. Introduction. Antenna Equivalent Circuit

General Porting Considerations. Memory EEPROM XRAM

8-bit Microcontroller. Application Note. AVR314: DTMF Generator

8-bit Microcontroller. Application Note. AVR201: Using the AVR Hardware Multiplier

AVR317: Using the Master SPI Mode of the USART module. 8-bit Microcontrollers. Application Note. Features. Introduction

Application Note. C51 Bootloaders. C51 General Information about Bootloader and In System Programming. Overview. Abreviations

AVR319: Using the USI module for SPI communication. 8-bit Microcontrollers. Application Note. Features. Introduction

Quick Start Guide. CAN Microcontrollers. ATADAPCAN01 - STK501 CAN Extension. Requirements

AVR134: Real Time Clock (RTC) using the Asynchronous Timer. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR106: C functions for reading and writing to Flash memory. 8-bit Microcontrollers. Application Note. Features. Introduction

8-bit Microcontroller. Application Note. AVR105: Power Efficient High Endurance Parameter Storage in Flash Memory

AVR245: Code Lock with 4x4 Keypad and I2C LCD. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR030: Getting Started with IAR Embedded Workbench for Atmel AVR. 8-bit Microcontrollers. Application Note. Features.

AT89C5131A Starter Kit... Software User Guide

8-bit Microcontroller. Application. Note. AVR204: BCD Arithmetics. Features. Introduction. 16-bit Binary to 5-digit BCD Conversion bin2bcd16

AVR32110: Using the AVR32 Timer/Counter. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR241: Direct driving of LCD display using general IO. 8-bit Microcontrollers. Application Note. Features. Introduction AVR

AT91 ARM Thumb Microcontrollers. AT91SAM CAN Bootloader. AT91SAM CAN Bootloader User Notes. 1. Description. 2. Key Features

3-output Laser Driver for HD-DVD/ Blu-ray/DVD/ CD-ROM ATR0885. Preliminary. Summary

AVR442: PC Fan Control using ATtiny13. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR034: Mixing C and Assembly Code with IAR Embedded Workbench for AVR. 8-bit Microcontroller. Application Note. Features.

AVR1301: Using the XMEGA DAC. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR32138: How to optimize the ADC usage on AT32UC3A0/1, AT32UC3A3 and AT32UC3B0/1 series. 32-bit Microcontrollers. Application Note.

AVR32100: Using the AVR32 USART. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR353: Voltage Reference Calibration and Voltage ADC Usage. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

USB 2.0 Full-Speed Host/Function Processor AT43USB370. Summary. Features. Overview

8-bit Microcontroller. Application Note. AVR134: Real-Time Clock (RTC) using the Asynchronous Timer. Features. Theory of Operation.

How To Prevent Power Supply Corruption On An 8Bit Microcontroller From Overheating

8-bit RISC Microcontroller. Application Note. AVR155: Accessing an I 2 C LCD Display using the AVR 2-wire Serial Interface

AVR127: Understanding ADC Parameters. Introduction. Features. Atmel 8-bit and 32-bit Microcontrollers APPLICATION NOTE

Application Note. Migrating from RS-232 to USB Bridge Specification USB Microcontrollers. Doc Control. References. Abbreviations

AVR1309: Using the XMEGA SPI. 8-bit Microcontrollers. Application Note. Features. 1 Introduction SCK MOSI MISO SS

AVR444: Sensorless control of 3-phase brushless DC motors. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR125: ADC of tinyavr in Single Ended Mode. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

ATF15xx Product Family Conversion. Application Note. ATF15xx Product Family Conversion. Introduction

Application Note. 8-bit Microcontrollers. AVR091: Replacing AT90S2313 by ATtiny2313. Features. Introduction

Using CryptoMemory in Full I 2 C Compliant Mode. Using CryptoMemory in Full I 2 C Compliant Mode AT88SC0104CA AT88SC0204CA AT88SC0404CA AT88SC0808CA

8-bit Microcontroller. Application Note. AVR461: Quick Start Guide for the Embedded Internet Toolkit. Introduction. System Requirements

Two-wire Automotive Serial EEPROM AT24C01A AT24C02 AT24C04 AT24C08 (1) AT24C16 (2)

AVR1600: Using the XMEGA Quadrature Decoder. 8-bit Microcontrollers. Application Note. Features. 1 Introduction. Sensors

USB Test Environment ATUSBTEST- SS7400. Summary

2-wire Serial EEPROM AT24C1024. Advance Information

DIGITAL-TO-ANALOGUE AND ANALOGUE-TO-DIGITAL CONVERSION

2-Wire Serial EEPROM AT24C32 AT24C64. 2-Wire, 32K Serial E 2 PROM. Features. Description. Pin Configurations. 32K (4096 x 8) 64K (8192 x 8)

Two-wire Serial EEPROM AT24C1024 (1)

Application Note. USB Mass Storage Device Implementation. USB Microcontrollers. References. Abbreviations. Supported Controllers

Application Note. 8-bit Microcontrollers. AVR307: Half Duplex UART Using the USI Module

b 1 is the most significant bit (MSB) The MSB is the bit that has the most (largest) influence on the analog output

AVR32788: AVR 32 How to use the SSC in I2S mode. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

Digital to Analog and Analog to Digital Conversion

DIP Top View VCC A16 A15 A12 A7 A6 A5 A4 A3 A2 A1 A0 I/O0 I/O1 I/O2 GND A17 A14 A13 A8 A9 A11 A10 I/O7 I/O6 I/O5 I/O4 I/O3. PLCC Top View VCC A17

AVR055: Using a 32kHz XTAL for run-time calibration of the internal RC. 8-bit Microcontrollers. Application Note. Features.

AVR1318: Using the XMEGA built-in AES accelerator. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

8-bit Microcontroller. Application Note. AVR410: RC5 IR Remote Control Receiver

3-output Laser Driver for HD-DVD/ Blu-ray/DVD/ CD-ROM ATR0885. Preliminary. Summary. Features. Applications. 1. Description

AVR1900: Getting started with ATxmega128A1 on STK bit Microcontrollers. Application Note. 1 Introduction

NTE2053 Integrated Circuit 8 Bit MPU Compatible A/D Converter

8-bit. Application Note. Microcontrollers. AVR282: USB Firmware Upgrade for AT90USB

Analog/Digital Conversion. Analog Signals. Digital Signals. Analog vs. Digital. Interfacing a microprocessor-based system to the real world.

AVR2006: Design and characterization of the Radio Controller Board's 2.4GHz PCB Antenna. Application Note. Features.

AVR033: Getting Started with the CodeVisionAVR C Compiler. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Application Note Microcontrollers. Guidelines to Keep ADC Resolution within Specification. Introduction. ADC Resolution

Application Note. 8-bit Microcontrollers. AVR280: USB Host CDC Demonstration. 1. Introduction

AVR32701: AVR32AP7 USB Performance. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

WHAT DESIGNERS SHOULD KNOW ABOUT DATA CONVERTER DRIFT

Step Motor Controller. Application Note. AVR360: Step Motor Controller. Theory of Operation. Features. Introduction

AP A/D Converter. Analog Aspects. C500 and C166 Microcontroller Families. Microcontrollers. Application Note, V 1.

STK 500, AVRISP, AVRISP

AVR2004: LC-Balun for AT86RF230. Application Note. Features. 1 Introduction

8-bit RISC Microcontroller. Application Note. AVR335: Digital Sound Recorder with AVR and DataFlash

All-band AM/FM Receiver and Audio Amplifier IC U2510B

Atmel AVR1017: XMEGA - USB Hardware Design Recommendations. 8-bit Atmel Microcontrollers. Application Note. Features.

Application Note. 8-bit Microcontrollers. AVR270: USB Mouse Demonstration

AVR1510: Xplain training - XMEGA USART. 8-bit Microcontrollers. Application Note. Prerequisites. 1 Introduction

APPLICATION NOTE Atmel AT02509: In House Unit with Bluetooth Low Energy Module Hardware User Guide 8-bit Atmel Microcontroller Features Description

Analog-to-Digital Converters

APPLICATION NOTE. Atmel AVR134: Real Time Clock (RTC) Using the Asynchronous Timer. Atmel AVR 8-bit Microcontroller. Introduction.

AT91 ARM Thumb Microcontroller. AT91M55800A Electrical Characteristics. Features. Description

AVR1922: Xplain Board Controller Firmware. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Section bit A/D Converter

Table of Contents. Section 1 Introduction Section 2 Getting Started Section 3 Hardware Description

256K (32K x 8) OTP EPROM AT27C256R 256K EPROM. Features. Description. Pin Configurations

AVR126: ADC of megaavr in Single Ended Mode. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

tinyavr Microcontrollers White Paper is the registered trademark of Atmel Corporation, 2325 Orchard Parkway, San Jose, CA Rev.

2-wire Serial EEPROM AT24C512

AVR318: Dallas 1-Wire master. 8-bit Microcontrollers. Application Note. Features. Introduction

AT91SAM ARM-based Flash MCU. Application Note. Analog-to-Digital Converter in the SAM3S4. 1. Introduction

Section 3. Sensor to ADC Design Example

Tire pressure monitoring

Conversion Between Analog and Digital Signals

TS555. Low-power single CMOS timer. Description. Features. The TS555 is a single CMOS timer with very low consumption:

Transcription:

Analog-to-digital Converter in the AT91M55800A Introduction Analog-to-digital converters translate analog measurements, characteristic of most phenomena in the real world, to digital format, used in information processing, computing, data transmission, and control systems. Terminology Table 1. Terminology Category Code Description Related to Numeric Base 0b Binary Notation AT91 ARM Thumb Microcontrollers Application Note 0x Hexadecimal Notation Related to Application LSB MSB FS A/D D/A S/H DNL INL SWRST EOC TIOA PIO PIO_PDR Least Significant Bit Most Significant Bit Full Scale Analog-to-Digital Digital-to-Analog Sampling and Hold Differential Non Linearity Integral Non Linearity Software Reset End Of Conversion Timer Input/Output A Parallel Input/Output PIO Disable Register

General Information Digital Quantities The best-known code is natural binary (base 2). Binary codes are most familiar in presenting integers; i.e., in a natural binary integer code having n bits, the LSB (Least Significant Bit) has a weight of 2 0 (i.e., 1), the next bit has a weight of 2 1 (i.e., 2), and so on up to the MSB (Most Significant Bit), which has a weight of 2 n-1 (i.e., 2 n /2). The integer value of the binary number is obtained by adding up the weights of all non-zero bits. In converter technology, because full scale (i.e., the converter s reference) is independent of the number of bits of resolution, a more useful coding is fractional binary, which is always normalized to full scale. Integer binary can be interpreted as fractional binary if all integer values are divided by 2 n. For example, the MSB has weight of 1/2 (i.e., 2 (n- 1) /2 n = 2-1 ), the next bit has a weight of 1/4 (i.e., 2 (n - 2) /2 n = 2-2 ), and so forth down to the LSB, which has a weight of 1/2 n (i.e., 2 -n ). When the weighted bits are added up, they form a number with any of 2 n values, from (1-2 -n ) of the full-scale. When all bits are 1 in natural binary, the fractional number value is 1-2 -n, or normalized full-scale less 1 LSB (1-1/16 = 1/15 in the 4-bit converter for example). The normalized numerical value of 10111001, an 8-bit code, is: 10111001 = 2 7 + 2 5 + 2 4 + 2 3 + 2 0 = 128 + 32 + 16 + 8 + 1 = 185 in integer binary and 2 7 2 5 2 4 2 3 2 0 128 32 16 8 1 ------ 2 8 + ------ 2 8 + ------ 2 8 + ------ 2 8 + ------ 2 8 = --------- + --------- + --------- + --------- + --------- = 256 256 256 256 256 2 1 + 2 3 2 4 2 5 2 8 1 1 1 1 1 + + + = -- + -- + ----- + ----- + --------- = 2 8 16 32 256 0.5 + 0.125 + 0.0625 + 0.0313 + 0.0039= 0.7227 185 --------- 256 185 --------- 256 in fractional binary. Bit numbering for microprocessor buses is based on whole numbers, not binary fractions. In such systems, the LSB is always Bit 0 (2 0 ), the MSB is always Bit n-1 (2 n-1 ). Setting up a correspondence between the bit numbers used in words in the two systems, we obtain Bit(n - 1): (2 n-1 ), Bit(n - 2): (2 n-2 ),. Bit(n - n) (i.e., 0): (2 0 = 1) in integer binary and Bit 1: (2-1 ), Bit 2: (2-2 )..Bit n: (2 -n ) in fractional binary. Basic Conversion Relationships A graph is often the most effective way of indicating in detail the relationship between analog and digital quantities in a conversion. Figure 1 shows the graph for an ideal 3-bit converter. Since all values of the analog input are presumed to exist, they must be quantized by partitioning the continuum into 8 discrete ranges. There is, therefore, in the A/D conversion process, an inherent quantization uncertainty of ± ½ LSB (see Figure 1), in addition to the conversion errors. 2 ADC in the AT91M55800A

ADC in the AT91M55800A Figure 1. Ideal A/D Conversion 1000 Ideal Transfer 111 110 Output Digital Number 101 100 Nominal Quantized Value (± 1 /2 LSB) 011 010 001 1/8 1/4 3/8 1/2 5/8 3/2 7/8 FS Normalized Analog Input +1/2 LSB Max. error 1/2 LSB -Max. error Nominal Quantized Value (± 1 /2 LSB) An n-bit converter is able to discriminate 2 n different states. We say that the resolution is equal to n bits. The relative accuracy is given by: r = 2 n For example, the resolution of a 3-bit analog-to-digital converter is equal to: r = 1 -- = 12.5% 8 An absolute resolution corresponds to this relative resolution depending on the full scale. For example, for a 3-bit analog-to-digital converter with a full scale equal to 2.5V, the absolute resolution is: r = 2.5 ------- = 0.3125V 8 Therefore, this resolution defines the smallest voltage input value that the ADC is able to discriminate: this is the quantum of conversion. As a result, in theory, the error induced by the conversion performed according to the analog value is ±1/2 LSB or ±1/2 n+1 %. 3

A/D Conversion Error Calculation Differential Nonlinearity Differential nonlinearity (DNL) in an ADC is defined as the deviation in code width from the value of 1 LSB (i.e., V FS /2 n ). Figure 2 illustrates an error equal to -0.8 LSB between the digital code 0b010 and 0b011: the gap between these codes is 0.2 LSB instead of 1 LSB, the DNL error is 0.8 LSB in this case. In this example, the DNL error is inferior to ±1 LSB and there is no missing code. Figure 2. DNL Error Inferior to ± 1 LSB 1000 Ideal Transfer 111 Output Digital Number 110 101 100-0.8LSB Nominal Quantized Value (± 1 /2 LSB) 011 010 001 1/8 1/4 3/8 1/2 5/8 3/2 7/8 FS Normalized Analog Input Figure 3 illustrates a DNL error between the code 0b100 and 0b110. The DNL error is equal to the real gap value between the code 0b100 and the next minus the 1 LSB theoretically expected: 2 LSB - 1 LSB = +1 LSB of DNL error in this case. Figure 3. DNL Error Greater Than 1 LSB 1000 111 +1LSB Output Digital Number 110 101 100 011 010 001 1/8 1/4 3/8 1/2 5/8 3/2 7/8 FS Normalized Analog Input In this last example, the DNL error is greater than 1 LSB, the code width vanishes entirely and the ADC has at least one missing code. 4 ADC in the AT91M55800A

ADC in the AT91M55800A Integral Nonlinearity Integral nonlinearity (INL) is the DNL error integration. The INL parameter indicates the gap value from the real converter result and the ideal transfer function. For example, in a 10-bit system, a ±2 LSB INL error advises the user a maximum nonlinearity equal to: ------------ 2 = 0.00195 or 0.2% 1024 Figure 4. Integral Nonlinearity Example Ideal Transfer 111 110 101 Output Digital 100 Number 011 INL Error 010 001 Real Transfer 1/8 1/4 3/8 1/2 5/8 3/2 7/8 FS Normalized Analog Input 5

Offset Error An offset error is defined as a common deviation from the ideal transition voltages. It is usually tested by finding the error of the first (LSB) transition, because it is likely that the offset error is the only significant error present in that transition. Figure 5. Offset Error Example Ideal Transfer 111 110 Output Digital Number 101 100 011 010 Real Transfer Curve 001 1/8 1/4 3/8 1/2 5/8 3/2 7/8 FS Normalized Analog Input 001 1/8 1/4 1 /2LSB 2 LSB Offset Error 6 ADC in the AT91M55800A

ADC in the AT91M55800A Gain Error Gain error appears as a change in slope of the transfer function. Thus, gain error is the same as full-scale error, except that the offset error is subtracted. Gain error affects each code in an equal ratio. Figure 6. Gain Error Example 111 Ideal Transfer Gain Error 110 Output Digital Number 101 100 011 Real Transfer Curve 010 001 1/8 1/4 3/8 1/2 5/8 3/2 7/8 FS VZS Normalized Analog Input V11 To determine the gain error of an ADC, measure the final transition voltage and subtract the first transition voltage. Since this interval is ideally equal to (V FS - 2 LSB), the deviation of the difference of the measured values from the value of (V FS - 2 LSB) is the fullscale gain error. The gain error can be expressed in LSBs. The gain error of Figure 6 may be determined by the following equation: Gain Error = ( V FS 2LSB) ( V 11 V ZS ) where: V 11 = final transition voltage V ZS = first transition voltage V FS - 2 LSB = full-scale range of the ADC minus 2 ideal LSBs. 7

Basic Characteristics of the Analog-to-digital Converter in the AT91M55800A Successive Approximations Successive-approximation A/D converters are widely used in the microcontroller domain. Conversion time is fixed and independent of the magnitude of the input voltage. Each conversion is unique and independent of the results of previous conversion because the internal logic is cleared at the start of a conversion. The conversion technique consists of comparing the unknown input against a precise voltage generated by a digital-to-analog converter. The input of the D/A converter is the digital number at the A/D converter s output. After the conversion command is applied and the converter has been cleared, the D/A converter s MSB output (½ full-scale) is compared with the input. If the input is greater than the MSB, it remains ON (i.e., 1 in the output register), and the next bit (1/4 full scale) is tried. If the input is less than the MSB, it is turned OFF (i.e., 0 in the output register), and the next bit is tried. If the second bit does not add enough weight to exceed the input, it is left ON (1), and the third bit is tried. The process continues in order of descending bit weight until the last bit has been tried. When the process is completed, the status line changes state to indicate that the contents of the output register now constitute a valid conversion. The content of the output register form a binary digital code corresponding to the input signal s magnitude. In terms of conversion time, this method gives the final result in n clock cycles. For example, with a 10-bit ADC, the conversion time is equal to 10 clock cycles. The embedded ADC in the AT91M55800A has an 8-bit conversion mode. In this mode, analog conversion is done over 10 bits and the 2 lowest significant bits are ignored. Thus, conversion time is not reduced, i.e., is equal to 10 cycles of the ADC clock. In the AT91M55800A, the sample and hold circuitry is integrated into the ADC cell. As a result, the full conversion process requires 11 clock cycles. Sample-Hold Circuit A circuit for an analog input channel in the AT91M55800A is shown in Figure 7. Figure 7. AT91M55800A Analog Input Channel ADx R CHANNEL CS/H where: ADx is an ADC input on the AT91M55800A C S/H is the sum of the parasitic capacitances due to package, pin-to-pin, and pin-topackage base coupling and the sampling capacitor circuit R CHANNEL is the equivalent resistance through the multiplexer circuitry the Sample/Hold switch When the switch is closed, the capacitor charges or discharges exponentially up to the input voltage. When the switch is opened, the charge or discharge remains on the capacitor s voltage. The charging time depends on the series resistance and the current available to charge the capacitor. Once the charge is acquired with the appropriate accuracy, the switch can be opened, even though the amplifier has not yet settled, without affecting the final output value. 8 ADC in the AT91M55800A

ADC in the AT91M55800A A disadvantage of this circuit is that the switched capacitor dynamically loads the input source, which may not have low enough output impedance and sufficient current-drive capacity in the given delay defined by the sampling period. The analysis of this constraint concerning the input equivalent impedance must take the requested accuracy and the sampling time into account over a full scale step of voltage at the input level. By analyzing the circuit as a first-order R-C system, the maximum impedance of the analog circuit driving an ADC input is defined by the formula: 2 Z max = ----------------------------------------------------------- 107 10 12 ----------------------- 1 -------------- 1 460 ln( 2) n 2 F ADC F MCK where: n is equal to 8 or 10 depending on the selected resolution F ADC is the ADC clock frequency F MCK is the Master Clock frequency of the microcontroller Dynamic and Static Measurements The formula above gives the maximum output impedance of the analog circuitry seen on the AT91M55800A s ADC input. Below this limit, the user is sure that the track voltage is correct, i.e., the charge transfer to the sampling capacitance has been fully completed. In order to stay below this limit in the dynamic domain, the use of an operational amplifier is recommended for two reasons: it has low output impedance (impedance adaptation) it allows adaptation voltage range input it allows implementation of an anti-alias filter (in dynamic domain) When the ADC is used in continuous domain as supply voltage, battery, temperature, etc., the application must resolve the discrepancy between the ADC full range input capability and the maximum level voltage of the information. The most efficient means for achieving this, taking into account ease of installation, cost and board space, is the use of a resistor bridge. See Figure 8. Figure 8. Basic Resistor Bridge V SENSOR I INJECTION R 1 I SENSOR To the ADC Input R 2 In order to decrease the continuous I SENSOR leakage through R1 and R2, the user selects the higher bridge value without exceeding the previously given Z MAX so that I IN- JECTION is sufficient. Adding a capacitance (see Figure 9) reduces the impedance of the circuitry in the tracking period. The charge injection, during this period, is not only completed through the 9

bridge resistor but also through the capacitor. By choosing a higher capacitance value compared to the sampling capacitor, it can be seen as a perfect voltage generator. Figure 9. Resistor Bridge with Added Capacitor V SENSOR R 1 I INJECTION I SENSOR To the ADC Input R 2 C 1 I INJECTION The value of the capacitor must be sufficient to transfer the necessary charges and show a voltage variation less than a quantum of conversion. Inversely, C 1 must not be overvalued: Out of the track period (between two consecutive measurement or a measurement sequence), the full load must be reach through the equivalent impedance equal to: R R 1 R 2 equivalent = ------------------ R 1 + R 2 The minimum required value can be expressed by the formula: C 1 = 2 n C S H V REF where: n is equal to 8 or 10 depending on the selected resolution C S/H is the sampling capacitor V REF is the reference voltage of the ADC 10 ADC in the AT91M55800A

ADC in the AT91M55800A Working with the Analog-to-digital Converter in the AT91M55800A Overview Figure 10 summarizes the settings required for an A/D conversion in the AT91M55800A. These settings are made via the User Interface. Figure 10. ADC Settings ADC Peripheral Converter Frequency 8-/10-bit ADC Output Enable the valid channel Triggering by: - Software - Timer/Counter Output - External Signal Between two conversions (or sequences): - Normal Mode - Sleep Mode Interrupt Event or not at End of Conversion Detailed Sampling Period The ADC peripheral can provide 8- or 10-bit output data. Note that the 8-bit mode does not decrease conversion time; in both modes, 11 ADC clock cycles are required to perform a full conversion. The major difference between the two modes is that in 8-bit mode data handling is easier when the software needs to work in byte mode. In 8-bit or 10-bit mode, an end of conversion (EOC) occurs for each channel and can generate an interrupt. The start of each conversion, or one sequence of analog-to-digital conversion, can be: software-triggered via the bit START in the register ADC_CR hardware-triggered via an embedded Timer/Counter output hardware-triggered via a dedicated input pin, AD0TRIG or AD1TRIG, depending on the targeted ADC The act of conversion can be for either: only one valid channel all valid channels In all modes, the conversion can be divided into two steps: sampling period conversion period 11

During the sampling period, the time during which the ADC s input tracks the analog voltage is equal to one ADC clock cycle minus two master clock cycles. See Figure 11. Figure 11. Sampling Period Ten Conversion Cycles ADC Clock One Sampling Cyle Mux. control event The ADC result is shifted to the respective ADC_CDRx register. The End Of Conversion occurs Microcontroller Master Clock EOC of the previous channel. Close the switch in front of the Sampling capacitor 2 Master Clock Cycles Figure 11 also shows that, in order to avoid a deterioration in sampling time due to both master clock cycles, it is important that the ADC frequency is lower than the master clock frequency. The calculation of input impedance takes this constraint into account. Enabling the ADC in the Advanced Power Management Peripheral Mode Register Settings After reset, in order to optimize power consumption, all peripheral clocks are stopped at the Advanced Power Management Controller level. As for other peripherals, before starting an analog-to-digital conversion, the user must enable the dedicated ADC clock in the APMC_PCER register (Peripheral Clock Enable Register). The ADC cell features a sleep mode to optimize power consumption. Sleep mode is enabled by setting the SLEEP bit in the Mode Register before starting the conversion. At the end of conversion, if sleep mode is enabled, the reference voltage used by the ADC is disconnected internally. It is important to note that setting the Software Reset bit (SWRST) in ADC_CR clears all status registers and all fields in the Mode Register. 12 ADC in the AT91M55800A

ADC in the AT91M55800A Trigger from a Timer/Counter Output Figure 12 summarizes the configuration for the Timer/Counter when it is used to trigger an A/D conversion. Figure 12. Timer/Counter Settings T/C Peripheral T/C in Wave Mode (TC_CMR Register) Select Clock Running Source (TC_CMR Register) Select the logical state when the software trigger occurs: CLEAR the output (TC_CMR Register) Select the logical state when an RA Compare occurs: SET the output (TC_CMR Register) Configure the value in the RA Register (TC_RA Register) Start the Timer/Counter A by: - Enabling the Counter Clock - Performing a software trigger (TC_CCR Register) When a Timer/Counter output is used to trigger the conversion, the multiplexed I/O controller must first be disabled on the targeted pin. The Timer/Counter outputs able to drive the ADC trigger inputs are: TIOA0, TIOA1, TIOA2, TIOA3, TIOA4, TIOA5. The PIO multiplexed lines are on the Timer/Counter output are, respectively: PB20, PB23, PB26, PA1, PA4 and PA7. The PIO_PDR register is used to disable the targeted PIO line and, at the same time, enable the multiplexed peripheral. Thus, at the PCB level, the user should not use a pin dedicated as ADC trigger signal. The user must enable the peripheral clock at the APMC level via the APMC_PCER register. Warning: Conversion on the First Valid Channel This Application Note gives the user the information required to calculate all the necessary external (analog characteristics) and internal (clock frequency and sampling time) parameters in order to use the ADC peripheral correctly. However, the behavior of the first valid channel during a conversion - in particular, at sampling time - shows the uncertainty about the duration of this step. 13

Figure 11 shows that the ADC clock is generated by dividing the Master Clock by a counter. This clock divider works as soon as a valid clock has been enabled on its input and cannot be reset other than by a hardware reset or the Software Reset bit (SWRST). For this reason, after the start of conversion, independent of the threshold source or the mode used in the ADC, it is not possible to know the duration of the sampling time. As a result, the required input characteristics cannot be specified. However, the use of one channel is possible by setting the SWRST bit in the Control Register and by starting the conversion immediately afterwards. In this case, the counter is reset and the sampling time can be anticipated. Figure 13 shows the steps necessary, and the fetch and execution time of those instructions reduce the sampling time. Therefore, it is important to evaluate this time correctly. Figure 13. Programming Steps SWRST Set the Mode Register Set the Valid Channels Start of Conversion In addition, the user must assure that these steps are completed without interruption. 14 ADC in the AT91M55800A

ADC in the AT91M55800A Document Details Title ADC in the AT91M55800A Literature Number 6039 Revision History Version A Publication Date: 29-Jan-04 15

Atmel Corporation 2325 Orchard Parkway San Jose, CA 95131, USA Tel: 1(408) 441-0311 Fax: 1(408) 487-2600 Regional Headquarters Europe Atmel Sarl Route des Arsenaux 41 Case Postale 80 CH-1705 Fribourg Switzerland Tel: (41) 26-426-5555 Fax: (41) 26-426-5500 Asia Room 1219 Chinachem Golden Plaza 77 Mody Road Tsimshatsui East Kowloon Hong Kong Tel: (852) 2721-9778 Fax: (852) 2722-1369 Japan 9F, Tonetsu Shinkawa Bldg. 1-24-8 Shinkawa Chuo-ku, Tokyo 104-0033 Japan Tel: (81) 3-3523-3551 Fax: (81) 3-3523-7581 Atmel Operations Memory 2325 Orchard Parkway San Jose, CA 95131, USA Tel: 1(408) 441-0311 Fax: 1(408) 436-4314 Microcontrollers 2325 Orchard Parkway San Jose, CA 95131, USA Tel: 1(408) 441-0311 Fax: 1(408) 436-4314 La Chantrerie BP 70602 44306 Nantes Cedex 3, France Tel: (33) 2-40-18-18-18 Fax: (33) 2-40-18-19-60 ASIC/ASSP/Smart Cards Zone Industrielle 13106 Rousset Cedex, France Tel: (33) 4-42-53-60-00 Fax: (33) 4-42-53-60-01 1150 East Cheyenne Mtn. Blvd. Colorado Springs, CO 80906, USA Tel: 1(719) 576-3300 Fax: 1(719) 540-1759 Scottish Enterprise Technology Park Maxwell Building East Kilbride G75 0QR, Scotland Tel: (44) 1355-803-000 Fax: (44) 1355-242-743 RF/Automotive Theresienstrasse 2 Postfach 3535 74025 Heilbronn, Germany Tel: (49) 71-31-67-0 Fax: (49) 71-31-67-2340 1150 East Cheyenne Mtn. Blvd. Colorado Springs, CO 80906, USA Tel: 1(719) 576-3300 Fax: 1(719) 540-1759 Biometrics/Imaging/Hi-Rel MPU/ High Speed Converters/RF Datacom Avenue de Rochepleine BP 123 38521 Saint-Egreve Cedex, France Tel: (33) 4-76-58-30-00 Fax: (33) 4-76-58-34-80 Literature Requests www.atmel.com/literature Disclaimer: Atmel Corporation makes no warranty for the use of its products, other than those expressly contained in the Company s standard warranty which is detailed in Atmel s Terms and Conditions located on the Company s web site. The Company assumes no responsibility for any errors which may appear in this document, reserves the right to change devices or specifications detailed herein at any time without notice, and does not make any commitment to update the information contained herein. No licenses to patents or other intellectual property of Atmel are granted by the Company in connection with the sale of Atmel products, expressly or by implication. Atmel s products are not authorized for use as critical components in life support devices or systems. Atmel Corporation 2004. All rights reserved. Atmel and combinations thereof is the registered trademark of Atmel Corporation or its subsidiaries. Other terms and product names may be the trademarks of others. Printed on recycled paper.