Microchip® Advanced Software Framework

Analog Comparator Controller - Example Interrupt Event Generation

Purpose

This example demonstrates how to use the ACC driver to perform a voltage comparison on a pair of inputs and generate an interrupt.

Requirements

This example can be used on the following evaluation kits:

  • SAM4S EK
  • SAM4S EK2

Description

The DAC0 and AD5 signals are selected as the inputs to the analog comparator. The user can change the output voltage of DAC0 and also change the voltage on AD5 by adjusting VR1 on the evaluation kit.

The DAC0 output voltage can be adjusted between (1/6)*ADVREF and (5/6)*ADVREF in software, whilst the input voltage on AD5 can vary between 0 and ADVREF.

A comparison interrupt event is generated when the input voltages are no longer equal.

Main Files

  • acc.c: Analog Comparator Controller driver
  • acc.h: Analog Comparator Controller driver header file
  • acc_example.c: Analog Comparator Controller example application

Compilation Information

This software is written for GNU GCC and IAR Embedded Workbench® for Atmel®. Other compilers may or may not work.

Usage

  1. Build the program and download it into the evaluation board.
  2. On the computer, open, and configure a terminal application (e.g., HyperTerminal on Microsoft® Windows®) with these settings:
    • 115200 baud
    • 8 bits of data
    • No parity
    • 1 stop bit
    • No flow control
  3. Start the application.
  4. In the terminal window, the following text should appear:
    -- ACC IRQ Example xxx --
    -- xxxxxx-xx
    -- Compiled: xxx xx xxxx xx:xx:xx --
    
    -- Menu Choices for this example--
    -- s: Set new DAC0 output voltage.--
    -- v: Get voltage on potentiometer.--
    -- m: Display this menu again.-- 
  5. Enter a character on the terminal to select a menu option.
  6. Change the voltage on AD5 by adjusting VR1 on the evaluation kit in order. To see what comparison events occur.