AVR1302: Using the XMEGA Analog Comparator. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Similar documents
AVR122: Calibration of the AVR's internal temperature reference. 8-bit Microcontrollers. Application Note. Features.

AVR1311: Using the XMEGA Timer/Counter Extensions. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

8-bit. Application Note. Microcontrollers. AVR077: Opto Isolated Emulation for the DebugWIRE

Flasher IC with 18-mΩ Shunt U6043B

UHF ASK/FSK Receiver ATA5721 ATA5722. Features

ATA6140. Flasher Application Module. Application Note. ATA Flasher Application Module. 1. Description

Current Monitor IC U4793B

AVR1003: Using the XMEGA Clock System. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Flasher, 18-mΩ Shunt, Frequency Doubling Disabling U6433B

Rad Hard 128K x volt Very Low Power CMOS SRAM M65609E

Flasher, 30 mω Shunt, Pilot Lamp to GND or V Batt U2043B

Flasher IC with U643B

4-Megabit (256K x 16) OTP EPROM AT27C4096

1-Megabit (64K x 16) OTP EPROM AT27C1024

256K (32K x 8) Unregulated Battery-Voltage High-Speed OTP EPROM AT27BV256

Zero-voltage Switch with Adjustable Ramp T2117

AVR1606: XMEGA Internal RC Oscillator Calibration. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Rad. Tolerant 8K x 8-5 volts Very Low Power CMOS SRAM AT65609EHW

AVR443: Sensor-based control of three phase Brushless DC motor. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Rad. Tolerant 128Kx8, 5-Volt Very Low Power CMOS SRAM M65608E

Atmel ATA6629/ Atmel ATA6631 Development Board V2.2. Application Note. Atmel ATA6629/ATA6631 Development Board V

8-bit Microcontroller with 2K Bytes In-System Programmable Flash. ATtiny261A. Appendix A. Appendix A ATtiny261A Specification at 105 C

Digital Window Watchdog Timer U5021M

Application Note. 8-Bit Microcontrollers. AVR433: Power Factor Corrector (PFC) with AT90PWM2 Re-triggable High Speed PSC

AVR32908: EVK1104 Getting Started Guide. 32-bit Microcontrollers. EVK1104 Getting Started Guide. Features. 1 Introduction

Transceiver Base Station Board ATAB542x-x-B. Application Note. Bill of Materials and Implementation of the Transceiver Base Station Board ATAB542x-x-B

Read/Write Base Station U2270B

PWM Power Control IC with Interference Suppression U6083B

IR Receiver for Data Communication U2538B

Transceiver Base Station Board ATAB5823-x-B/ ATAB5824-x-B. Application Note

300-MHz Quadrature Modulator U2793B

Atmel U6032B. Automotive Toggle Switch IC DATASHEET. Features. Description

Rear Window Heating Timer/ Long-term Timer U6046B

Two-relay Flasher ATA6140

ATF15xx Power-On Reset Hysteresis Feature. Abstract. Features. Complex Programmable Logic Device APPLICATION NOTE

Atmel RF Products. RF Selection Guide

Low-cost Phase-control IC with Soft Start U2008B

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

Low-cost Phase-control IC with Soft Start

All-in-One IC Solution for Active Antennas ATR4252. Summary

Frequency Synthesizer for Radio Tuning ATR4256

Can Transceiver IC B10011S

AVR443: Sensorbased control of three phase Brushless DC motor. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Low-power Audio Amplifier for Telephone Applications U4083B

Read/Write Crypto Transponder for Short Cycle Time TK5561A-PP

Zero-voltage Switch with Adjustable Ramp T2117

APPLICATION NOTE. Atmel AVR127: Understanding ADC Parameters. Atmel 8-bit Microcontroller. Features. Introduction

AVR042: AVR Hardware Design Considerations. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Application Note. How to Connect C51 Microcontroller to ATR Microcontrollers

256K (32K x 8) Unregulated Battery. Programmable, Read-only Memory

Low-power Flasher IC with 18-m Shunt U6432B

1Mb (128K x 8) Low Voltage, One-time Programmable, Read-only Memory

1Mb (128K x 8) Unregulated Battery Voltage, One-time Programmable, Read-only Memory

1Mb (64K x 16) Unregulated Battery Voltage, High-speed, One-time Programmable, Read-only Memory

APPLICATION NOTE. AT11009: Migration from ATxmega64D3/128D3/192D3/256D3 Revision E to Revision I. Introduction. Features.

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

1-Megabit (64K x 16) OTP EPROM AT27C1024

8Mb (1M x 8) One-time Programmable, Read-only Memory

512K (64K x 8) Unregulated Battery. Programmable, Read-only Memory

Application Note. 8-bit Microcontrollers. AVR092: Replacing ATtiny11/12 by ATtiny13. Features. Introduction

2-Megabit (128K x 16) OTP EPROM AT27C2048

AT15291: Migrating QTouch Designs from SAM D MCUs to SAM C MCUs. Scope. Features. QTouch APPLICATION NOTE

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

Phase-control IC with Current Feedback and. Overload. Protection U2010B

Introduction. Reference Documents. AFE Calibration on SAM V/E/S7x Microcontrollers. SMART ARM-based Microcontrollers APPLICATION NOTE

APPLICATION NOTE. ATA6629/ATA6631 Development Board V2.2 ATA6629/ATA6631. Introduction

1-Megabit (128K x 8) OTP EPROM AT27C010

Low-noise, High-dynamicrange. Antenna Amplifier IC ATR4251

AVR221: Discrete PID Controller on tinyavr and megaavr devices. Introduction. AVR 8-bit Microcontrollers APPLICATION NOTE

AVR1300: Using the Atmel AVR XMEGA ADC. 8-bit Microcontrollers. Application Note. Preliminary. Features. 1 Introduction

Atmel LED Driver Technology. Smart LED Power Management for Efficiency, Programmability and Scalability

Atmel ATA5791. Embedded AVR Microcontroller Including RF Transmitter and Complete LF Functionality for Passive Entry/Passive Start Keys

Power Meter Front End Design: The Delta Connection. Application Note. Power Meter Front End Design: The Delta Connection. Three-Phase Basics

QTouch Capacitive Touch Technology Copyright Atmel Atmel Corporation

Designing With CryptoAuthentication Client Devices

Application Note. Preliminary. 8-bit Microcontrollers

Fast read access time 70ns Low-power CMOS operation 100μA max standby 30mA max active at 5MHz. JEDEC standard packages 32-lead PDIP 32-lead PLCC

Phase-control IC with Current Feedback and. Overload. Protection

AVR42778: Core Independent Brushless DC Fan Control Using Configurable Custom Logic on ATtiny817. Features. Introduction. AVR 8-bit Microcontroller

128-bit Read-only IDIC for RF Identification. e5530

Atmel ATR4253C. Integrated Circuit Solution for Active Antennas DATASHEET. Features

UHF ASK Transmitter U2745B

APPLICATION NOTE. Atmel AVR2067: Crystal Characterization for AVR RF. Atmel MCU Wireless. Features. Description

1000-MHz Quadrature Modulator U2790B. Features. Benefits. Description. Electrostatic sensitive device. Observe precautions for handling.

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

MHz High Linearity SiGe Active Receive Mixer T0782. Preliminary

8-bit Microcontroller. Application Note. AVR084: Replacing ATmega323 by ATmega32. Features. Introduction. ATmega323 Errata Corrected in ATmega32

AT14164: User Calibration of Internal Temperature Sensor - SAM R21. Introduction. SMART ARM-based MCUs APPLICATION NOTE

ShortLink Wide Band Antenna Family Models: SLA150-SMA, SLA150-UFL. Wide Band Antenna Family SLA150 Datasheet

Atmel LED Driver-MSLB9061 LED Driver Module. Compact, 6-channel LED Driver Board with I 2 C Interface. Datasheet

Programmable SLI AT94K AT94S. Application Note. DTMF Generator

Read/Write Base Station U2270B

8Mb (1M x 8) One-time Programmable, Read-only Memory

Standard Read/Write ID Transponder with Anticollision TK5551

ATAVRAUTO User Guide

8-Megabit (1M x 8) OTP EPROM AT27C080. Features. Description. Pin Configurations

Highperformance EE PLD ATF16LV8C

4-Megabit (512K x 8) OTP EPROM AT27C040. Features. Description. Pin Configurations

2.4-GHz SiGe Power Amplifier for b/g WLAN Systems T7031. Preliminary

UHF ASK/FSK Transmitter U2741B

Transcription:

AVR1302: Using the XMEGA Analog Comparator Features Flexible Input Selection High-speed vs. Low-power Option Selectable Input Hysteresis Comparator 0 Output Available on I/O Pin Scalable Voltage References Window Mode 8-bit Microcontrollers Application Note 1 Introduction The XMEGA Analog Comparator (AC) module is a high-performance dualcomparator module with flexible multiplexer (MUX) settings, integrated voltage reference scaler and several configuration options. It also has an option to combine and compare the internal comparator outputs in order to implement a window function. This application note describes the basic functionality of the XMEGA AC with code examples to get up and running quickly. A driver interface written in C is included as well. Figure 1-1. Analog Comparator Overview Pin inputs AC0 Pin 0 Output Internal inputs Scaler AC1 Interrupt sensitivity control Interrupts Events Rev.

2 Module Overview This section provides an overview of the basic configuration options and functionality of the Analog Comparator. Section 3 then walks you through the basic steps to get up and running, with register descriptions and configuration details. 2.1 Comparator Operation 2.2 High-speed vs. Low-power Option 2.3 Selectable Input Hysteresis Each comparator block has its own set of control and MUX selection registers. For all intents and purposes, they can be operated independently. In general, if the positive input signal is above the negative input, then the comparator output is logic one, and logic zero otherwise. Each comparator s MUX Control register (ACnMUXCTRL) selects the signals to use for the positive and negative input. The positive input can be connected to analog input pin AC0, AC1, AC2, AC4, AC5 or AC6. The negative input can be connected to analog input pin AC0, AC1, AC3, AC5 or AC7. In addition, the inputs can also choose one of the following internal signals: The output from the 12-bit DAC, the Bandgap Reference or the internal voltage scaler for the Analog Comparator module. Only the DAC output is available on the positive input pin. The voltage scaler is covered in Section 2.5 below. Each comparator can be configured for either high-speed performance or low-power operation. By setting the High-speed Mode bit (HSMODE) in each comparator s Control register (ACnCTRL), that comparator will be biased towards high-speed operation. Clearing the bit increases the propagation delay in the comparator but lowers the power consumption. The two comparator blocks can be configured individually. Each comparator can be configured for no, low or high hysteresis. For applications that compare signals that are very close to each other, increasing the hysteresis would help avoid excessive toggling of the comparator output if the signals are noisy. The hysteresis level is configured with the Hysteresis Mode bitfield (HYSMODE) in each comparator s Control register (ACnCTRL). The two comparator blocks can be configured individually. Figure 2-1 below illustrates the different hysteresis settings. 2 AVR1302

AVR1302 Figure 2-1. Different Hysteresis Settings Pos. input Neg. input No hysteresis Comp. output Pos. input Neg. input Low hysteresis Comp. output Pos. input Neg. input High hysteresis Comp. output 2.4 The Common Status Register Please refer to the device datasheet for details on the electrical characteristics for the hysteresis settings. The Status register (STATUS) for the Analog Comparator module covers current status and interrupt flags for both comparator blocks. The two Comparator State bits (ACnSTATE) is directly linked to the output of the comparator blocks and shows the current status for each comparator. The two Interrupt Flag bits (AcnIF) gets set to logic one when an interrupt condition occurs, regardless if interrupts are enabled or not. Each comparator can be configured to give an interrupt condition every time the output toggles, on positive edges on the output or on negative edges. This is configured with the Interrupt Mode bitfield (INTMODE) in each comparator s Control register (ACnCTRL). The same distinguishing between state bit and interrupt flag applies to the Window Mode State bit (WSTATE) and Window Mode Interrupt Flag bit (WIF) in the Status register (STATUS). Window mode is covered in Section 2.6 below. 2.5 Voltage Scaler One of the input selections for the comparators is the internal voltage scaler connected to VCC. This is a 6-bit DAC internal in the Analog Comparator module. Being a 6-bit DAC, voltages can be generated in 64 discrete steps from 0V to 63/64ths of the VCC. Figure 2-2 below shows an overview of the voltage scaler. 3

Figure 2-2. Voltage Scaler Overview VCC DAC Input/64 * [0..63] 0..63 Control Register B The scale factor is selected with the Voltage Scaler Factor bitfield (SCALEFAC) in the Control Register B (CTRLB). 2.6 Window Mode The window mode is intended for monitoring a signal against a certain voltage range, or window. While the comparator outputs show whether a signal is above or below another, the window mode output shows whether a signal is above, below or inside a voltage range. Interrupt conditions can be given when the signal is inside, outside, above or below the voltage range. Window mode is enabled with the Window Mode Enable bit (WEN) in the Window Mode Control register (WINCTRL). The interrupt condition is configured with the Window Mode Interrupt Mode bitfield (WINTMODE) in the same register. Figure 2-3. Connection Setup for Window Mode Upper window limit Monitored signal Lower window limit + - + - AC0 AC1 Interrupt sensitivity control Interrupts Events 2.7 Comparator 0 Output Available on Output Pin Positive and negative inputs for the two comparators are selected by using the multiplexers in the same way as for traditional operation. In order to use the window function, you need to externally connect comparator 0 s positive input to comparator 1 s positive input, or direct both MUXes to the same input. This junction also connects to the monitored signal. Current window state and associated interrupt flag can be found in the Status register (STATUS), as described in 2.4 above. By setting the Comparator 0 Output Enable bit (AC0OUT) in Control Register A (CTRLA), the output from comparator block 0 is connector to the analog output pin AC0OUT. Comparator 0 must be configured and enabled in order for this feature to work. The output is digital, and reads logic one if the positive input is above the negative input, and vice versa. 4 AVR1302

AVR1302 3 Getting Started The necessary few steps to get up and running with comparators is as follows: 1. Configure MUX settings for the comparators you want to use. 2. Configure which interrupt condition to use for each comparator. 3. Configure interrupt levels if you want to use interrupt handlers. 4. Enable the comparators you want to use. For a detailed example comparator setup and use and how to use the window mode, please study the example software for this application note. 4 Driver Implementation 4.1 Files This application note includes a source code package with a basic AC driver implemented in C. It is written for the IAR Embedded Workbench compiler. Note that this AC driver is not intended for use with high-performance code. It is designed as a library to get started with the AC. For timing and code space critical application development, you should access the AC registers directly. Please refer to the driver source code and device datasheet for more details. The source code package consists of three files: ac_driver.c AC driver source file ac_driver.h AC driver header file AC_example_polled.c Example code using the AC driver using one comparator with hysteresis and polled functions. AC_example_window_and_interrupt.c Example code using the AC in window mode and with interrupts. 4.2 Doxygen Documentation For a complete overview of the available driver interface functions and their use, please refer to the source code documentation. All source code is prepared for automatic documentation generation using Doxygen. Doxygen is a tool for generating documentation from source code by analyzing the source code and using special keywords. For more details about Doxygen please visit http://www.doxygen.org. Precompiled Doxygen documentation is also supplied with the source code accompanying this application note, available from the readme.html file in the source code folder. 5

Disclaimer Headquarters International Atmel Corporation 2325 Orchard Parkway San Jose, CA 95131 USA Tel: 1(408) 441-0311 Fax: 1(408) 487-2600 Atmel Asia Room 1219 Chinachem Golden Plaza 77 Mody Road Tsimshatsui East Kowloon Hong Kong Tel: (852) 2721-9778 Fax: (852) 2722-1369 Atmel Europe Le Krebs 8, Rue Jean-Pierre Timbaud BP 309 78054 Saint-Quentin-en- Yvelines Cedex France Tel: (33) 1-30-60-70-00 Fax: (33) 1-30-60-71-11 Atmel 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 Product Contact Web Site www.atmel.com Technical Support avr@atmel.com Sales Contact www.atmel.com/contacts Literature Request www.atmel.com/literature Disclaimer: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN ATMEL S TERMS AND CONDITIONS OF SALE LOCATED ON ATMEL S WEB SITE, ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and product descriptions at any time without notice. Atmel does not make any commitment to update the information contained herein. Unless specifically provided otherwise, Atmel products are not suitable for, and shall not be used in, automotive applications. Atmel s products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life. 2008 Atmel Corporation. All rights reserved. Atmel, logo and combinations thereof, AVR and others, are the registered trademarks or trademarks of Atmel Corporation or its subsidiaries. Other terms and product names may be trademarks of others.