APPLICATION NOTE. AVR1302: Using the XMEGA Analog Comparator. Atmel AVR 8-bit Microcontrollers. Features. Introduction

Similar documents
How To Use An Atmel Atmel Avr32848 Demo For Android (32Bit) With A Microcontroller (32B) And An Android Accessory (32D) On A Microcontroller (32Gb) On An Android Phone Or

APPLICATION NOTE. Atmel AT04389: Connecting SAMD20E to the AT86RF233 Transceiver. Atmel SAMD20. Description. Features

Application Note. Atmel ATSHA204 Authentication Modes. Prerequisites. Overview. Introduction

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

Atmel AVR4921: ASF - USB Device Stack Differences between ASF V1 and V2. 8-bit Atmel Microcontrollers. Application Note. Features.

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

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

APPLICATION NOTE. Atmel AVR443: Sensor-based Control of Three Phase Brushless DC Motor. Atmel AVR 8-bit Microcontrollers. Features.

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

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

APPLICATION NOTE. Atmel LF-RFID Kits Overview. Atmel LF-RFID Kit. LF-RFID Kit Introduction

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

Application Note. Atmel CryptoAuthentication Product Uses. Atmel ATSHA204. Abstract. Overview

Atmel AVR4920: ASF - USB Device Stack - Compliance and Performance Figures. Atmel Microcontrollers. Application Note. Features.

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

32-bit AVR UC3 Microcontrollers. 32-bit AtmelAVR Application Note. AVR32769: How to Compile the standalone AVR32 Software Framework in AVR32 Studio V2

Introducing a platform to facilitate reliable and highly productive embedded developments

Atmel AVR4903: ASF - USB Device HID Mouse Application. Atmel Microcontrollers. Application Note. Features. 1 Introduction

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

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

APPLICATION NOTE. Atmel AT02985: User s Guide for USB-CAN Demo on SAM4E-EK. Atmel AVR 32-bit Microcontroller. Features. Description.

APPLICATION NOTE. Atmel AT01095: Joystick Game Controller Reference Design. 8-/16-bit Atmel Microcontrollers. Features.

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

How To Design An Ism Band Antenna For 915Mhz/2.4Ghz Ism Bands On A Pbbb (Bcm) Board

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

AVR1321: Using the Atmel AVR XMEGA 32-bit Real Time Counter and Battery Backup System. 8-bit Microcontrollers. Application Note.

AT91SAM ARM-based Flash MCU. Application Note

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

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

APPLICATION NOTE. Atmel AVR600: STK600 Expansion, Routing and Socket Boards. Atmel Microcontrollers. Introduction

AVR287: USB Host HID and Mass Storage Demonstration. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

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

AVR151: Setup and Use of the SPI. Introduction. Features. Atmel AVR 8-bit Microcontroller APPLICATION NOTE

AVR115: Data Logging with Atmel File System on ATmega32U4. Microcontrollers. Application Note. 1 Introduction. Atmel

USER GUIDE EDBG. Description

AVR1324: XMEGA ADC Selection Guide. 8-bit Atmel Microcontrollers. Application Note. Features. 1 Introduction

Atmel AVR ATxmega384C3 microcontroller OLED display with pixels resolution Analog sensors. Ambient light sensor Temperature sensor

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

Software Prerequisites Linux Ubuntu LTS. Estimated completion time: 15min. The goal of this hands-on is to:

Atmel AT32UC3A3256 microcontroller 64MBit SDRAM Analog input (to ADC) Temperature sensor RC filter

Atmel AVR4027: Tips and Tricks to Optimize Your C Code for 8-bit AVR Microcontrollers. 8-bit Atmel Microcontrollers. Application Note.

General Porting Considerations. Memory EEPROM XRAM

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

8051 Flash Microcontroller. Application Note. A Digital Thermometer Using the Atmel AT89LP2052 Microcontroller

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

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

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

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

Two mechanical buttons Two user LEDs Four expansion headers. Board controller with USB interface. One power LED and one status LED

AT88CK490 Evaluation Kit

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

APPLICATION NOTE. Secure Personalization with Transport Key Authentication. ATSHA204A, ATECC108A, and ATECC508A. Introduction.

Application Note. 1. Introduction. 2. Associated Documentation. 3. Gigabit Ethernet Implementation on SAMA5D3 Series. AT91SAM ARM-based Embedded MPU

APPLICATION NOTE. Atmel AVR2033: SAM-ICE Adapter Hardware User Manual. 8-bit Atmel Microcontrollers. Features. Introduction

SMARTCARD XPRO. Preface. SMART ARM-based Microcontrollers USER GUIDE

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

APPLICATION NOTE. Atmel AT01180: Barcode and QR code scanner User Guide. Atmel 32-bit Microcontroller. Features. Introduction

APPLICATION NOTE. AT03155: Real-Time-Clock Calibration and Compensation. SAM3 / SAM4 Series. Scope

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

APPLICATION NOTE. Authentication Counting. Atmel CryptoAuthentication. Features. Introduction

USER GUIDE. ZigBit USB Stick User Guide. Introduction

1Mb (64K x 16) One-time Programmable Read-only Memory

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

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

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

APPLICATION NOTE. Atmel AVR1300: Using the Atmel AVR XMEGA ADC. Atmel 8-bit Microcontrollers PRELIMINARY. Introduction

APPLICATION NOTE. AT07175: SAM-BA Bootloader for SAM D21. Atmel SAM D21. Introduction. Features

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

AVR131: Using the AVR s High-speed PWM. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

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

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

AT15007: Differences between ATmega328/P and ATmega328PB. Introduction. Features. Atmel AVR 8-bit Microcontrollers APPLICATION NOTE

Application Note. 8-bit Microcontrollers. AVR272: USB CDC Demonstration UART to USB Bridge

Practical PCB design techniques for wireless ICs Controlled impedance layout 100Ω balanced transmission lines

APPLICATION NOTE. AT16268: JD Smart Cloud Based Smart Plug Getting. Started Guide ATSAMW25. Introduction. Features

APPLICATION NOTE. Atmel AT02845: Coexistence between ZigBee and Other 2.4GHz Products. Atmel MCU Wireless. Description. Features

CryptoAuth Xplained Pro

8-bit Atmel Microcontrollers. Application Note. Atmel AVR211: Wafer Level Chip Scale Packages

Section 1 Introduction to the AT91SAMD20 and the Development Environment

Atmel AVR4950: ASF - USB Host Stack. 8-bit Atmel Microcontrollers. Application Note. Features. 1 Introduction

Designing Feature-Rich User Interfaces for Home and Industrial Controllers

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

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

AVR106: C Functions for Reading and Writing to Flash Memory. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

QT1 Xplained Pro. Preface. Atmel QTouch USER GUIDE

Atmel AVR1618: ATxmegaB ASCII Character Mapping. 8-bit Atmel Microcontrollers. Application Note. Features. 1 Introduction

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

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

AT11805: Capacitive Touch Long Slider Design with PTC. Introduction. Features. Touch Solutions APPLICATION NOTE

AN2680 Application note

Quest vworkspace Virtual Desktop Extensions for Linux

256K (32K x 8) Battery-Voltage Parallel EEPROMs AT28BV256

AVR315: Using the TWI Module as I2C Master. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

Atmel AVR4905: ASF - USB Device HID Generic. 8-/32-bit Atmel Microcontrollers. Application Note. Features. 1 Introduction

Application Note. 8-bit Microcontrollers. AVR293: USB Composite Device

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

Proximity Design Guide. Proximity Design Guide. Application Note QTAN Introduction

Capacitive Touch Technology Opens the Door to a New Generation of Automotive User Interfaces

More Secure, Less Costly IoT Edge Node Security Provisioning

AVR311: Using the TWI Module as I2C Slave. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

Transcription:

APPLICATION NOTE AVR1302: Using the XMEGA Analog Comparator Atmel AVR 8-bit Microcontrollers 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 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. Analog Comparator Overview. Pin inputs AC0 Pin 0 Output Internal inputs Scaler AC1 Interrupt sensitivity control Interrupts Events

1. Module Overview This section provides an overview of the basic configuration options and functionality of the Analog Comparator. Chapter 2 then walks you through the basic steps to get up and running, with register descriptions and configuration details. 1.1 Comparator Operation 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 1.5. 1.2 High-speed vs. Low-power Option Each comparator can be configured for either high-speed performance or low-power operation. By setting the Highspeed 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. 1.3 Selectable Input Hysteresis 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 bit field (HYSMODE) in each comparator s Control register (ACnCTRL). The two comparator blocks can be configured individually. Figure 1-1 illustrates the different hysteresis settings. 2

Figure 1-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 Refer to the device datasheet for details on the electrical characteristics for the hysteresis settings. 1.4 The Common Status Register 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) are directly linked to the output of the comparator blocks and shows the current status for each comparator. The two Interrupt Flag bits (AcnIF) get 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 bit field (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 1.6. 1.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 1/64 * VCC to VCC. Figure 1-2 shows an overview of the voltage scaler. 3

Figure 1-2. Voltage Scaler Overview. VCC DAC VCC*(SCALEFAC+1)/64 SCALEFAC Control Register B The scale factor is selected with the Voltage Scaler Factor bit field (SCALEFAC) in the Control Register B (CTRLB). 1.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 bit field (WINTMODE) in the same register. Figure 1-3. Connection Setup for Window Mode. + Upper window limit Monitored signal Lower window limit - + - AC0 AC1 Interrupt sensitivity control Interrupts Events 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 Section 1.4. 1.7 Comparator 0 Output Available on Output Pin 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

2. 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, study the example software for this application note. 3. Driver Implementation 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: 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. Refer to the driver source code and device datasheet for more details. 3.1 Files 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. For a complete overview of the available driver interface functions and their use, refer to the source code documentation. 3.2 Doxygen 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, 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

4. Revision History Doc. Rev. Date Comments 8041C 07/2013 A bug (AN-3842) is fixed 8041B 04/2008 Updated F_CPU define and GCC compatible 8041A 02/2008 Initial document release 6

Atmel Corporation 1600 Technology Drive San Jose, CA 95110 USA Tel: (+1)(408) 441-0311 Fax: (+1)(408) 487-2600 www.atmel.com Atmel Asia Limited Unit 01-5 & 16, 19F BEA Tower, Millennium City 5 418 Kwun Tong Road Kwun Tong, Kowloon HONG KONG Tel: (+852) 2245-6100 Fax: (+852) 2722-1369 Atmel Munich GmbH Business Campus Parkring 4 D-85748 Garching b. Munich GERMANY Tel: (+49) 89-31970-0 Fax: (+49) 89-3194621 Atmel Japan G.K. 16F Shin-Osaki Kangyo Building 1-6-4 Osaki, Shinagawa-ku Tokyo 141-0032 JAPAN Tel: (+81)(3) 6417-0300 Fax: (+81)(3) 6417-0370 2013 Atmel Corporation. All rights reserved. / Rev.: Atmel, Atmel logo and combinations thereof, Enabling Unlimited Possibilities, XMEGA, and others are registered trademarks or trademarks of Atmel Corporation or its subsidiaries. Other terms and product names may be trademarks of others. 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 THE ATMEL TERMS AND CONDITIONS OF SALES LOCATED ON THE ATMEL WEBSITE, 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 AND 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 products 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 products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life.