background image

 AVR 8-bit Microcontrollers

 AVR128: Setup and Use of the AVR Analog

Comparator

 APPLICATION NOTE

Introduction

This application note serves as an example on how to set up and use the
Atmel

®

 AVR

®

 On-chip Analog Comparator. The following program examples

are given in the assembly file “avr200.asm”:

Detect a positive edge on the comparator output by polling the ACO-
bit in the Analog Comparator Control and Status Register – ACSR.

Detect a positive edge on the comparator output by polling the Analog
Comparator Interrupt Flag – ACI in ACSR.

Initialize interrupt on comparator output toggle. An interrupt routine
which increments a 16-bit counter each time it is executed is given as
an example.

Atmel-0934C-Setup-and-Use-of-the-AVR-Analog-Comparator_AVR128_Application Note-07/2016

Содержание AVR128

Страница 1: ...00 asm Detect a positive edge on the comparator output by polling the ACO bit in the Analog Comparator Control and Status Register ACSR Detect a positive edge on the comparator output by polling the Analog Comparator Interrupt Flag ACI in ACSR Initialize interrupt on comparator output toggle An interrupt routine which increments a 16 bit counter each time it is executed is given as an example Atme...

Страница 2: ...CO 3 2 Detecting a Positive Edge by Polling ACI 4 3 Using the Analog Comparator Interrupt 6 4 Revision History 7 Atmel AVR128 Setup and Use of the AVR Analog Comparator APPLICATION NOTE Atmel 0934C Setup and Use of the AVR Analog Comparator_AVR128_Application Note 07 2016 2 ...

Страница 3: ...ng a short pulse will increase Such code might be time out if no edge occurs within a specific period The procedure for detection is as follows 1 If output is high wait for output to go low 2 Wait until output goes high Figure 1 1 ACO Polling Flow Chart START N Y DONE ACO 0 N Y ACO 1 Table 1 1 ACO Polling Performance Figures Parameter Value Code Size Words 4 Response Time Cycles 3 5 Initialization...

Страница 4: ...k for has occurred since the last ACI Reset In this application note positive edge detection by polling ACI is implemented according to the following procedure Setup 1 Set ACIS0 and ACIS1 1 Polling 1 Clear the ACI bit by writing a logical 1 to it 2 Wait until ACI goes high Figure 2 1 ACI Polling Flow Chart SETUP DONE N Y ACO 1 ACIS1 ACIS0 11 CLEAR ACI Table 2 1 ACI Polling Performance Figures Para...

Страница 5: ...nterrupts Usage None Peripherals Usage Analog Comparator Atmel AVR128 Setup and Use of the AVR Analog Comparator APPLICATION NOTE Atmel 0934C Setup and Use of the AVR Analog Comparator_AVR128_Application Note 07 2016 5 ...

Страница 6: ... selects interrupt on toggle 2 Enable Global Interrupts 3 Enable the Analog Comparator Interrupt by setting the ACIE bit in ACSR Note that since the ACSR Register is one of the lower 32 I O registers the SBI instruction can be used to set clear and test bits Table 3 1 Analog Comparator Interrupt Enable Performance Figures Parameter Value Code Size Words 4 Execution Time Cycles 5 Register Usage Low...

Страница 7: ...ents 0934C 07 2016 New template 0934B 05 2002 0934A Initial document release Atmel AVR128 Setup and Use of the AVR Analog Comparator APPLICATION NOTE Atmel 0934C Setup and Use of the AVR Analog Comparator_AVR128_Application Note 07 2016 7 ...

Страница 8: ...R 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 contain...

Отзывы: