Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ADC Threshold Wakeup Example

Purpose

The adc_threshold_wakeup example demonstrates how to use ADC with threshold wakeup.

Requirements

This example can be used on any SAM3/4 boards.

ADVREF must be set to 3300 mv in order to enable full scale measurement of the potentiometer. Please refer to the board schematics for ADVREF jumper configuration.

Description

This example uses TIOA0 as external trigger instead of software trigger for ADC conversion. The TIOA0 is a 1ms period square wave. The rising edge during each period would trigger the ADC to start a conversion on the given channel which is connected to the potentiometer. This example shows a menu as below upon running:

-- Menu Choices for this example--
-- 0: Display voltage on potentiometer.--
-- 1: Modify low threshold.--
-- 2: Modify high threshold.--
-- 3: Choose comparison mode.--
-- i: Display ADC information.--
-- m: Display this main menu.--
-- c: Set Auto Calibration Mode. --
-- s: Enter sleep mode.--

With the user interface, comparison window and mode could be set. The ADC supports 4 kinds of comparison events as follows:

  • Lower than the low threshold.
  • Higher than the high threshold.
  • In the comparison window.
  • Out of the comparison window.

If the target gets an 'S' or 's' from user's input, the core falls into sleep mode thanks to the __WFI. Turning the potentiometer to enable the ADC input fall into the comparison window will trigger an event. This comparison event will wake the system up.

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 bauds
    • 8 bits of data
    • No parity
    • 1 stop bit
    • No flow control
  3. In the terminal window, the following text should appear (values depend on the board and the chip used):
    -- ADC Threshold Wakeup Example xxx --
    -- xxxxxx-xx
    -- Compiled: xxx xx xxxx xx:xx:xx --
    -- Menu Choices for this example--
    -- 0: Display voltage on potentiometer.--
    -- 1: Modify low threshold.--
    -- 2: Modify high threshold.--
    -- 3: Choose comparison mode.--
    -- i: Display ADC information.--
    -- m: Display this main menu.--
    -- c: Set Auto Calibration Mode. --
    -- s: Enter sleep mode.--
  4. Input the command according to the menu.