Microchip® Advanced Software Framework

Asynchronous Timer (AST) - Example 2 Alarm Wakeup

Purpose

This example demonstrates how to use the AST driver with the 32kHz oscillator crystal and to also setup an alarm to wake-up the device from its low power modes.

Requirements

This example can be used with SAM4L evaluation kits.

Description

Upon startup, the program uses the USART driver to display a menu that lets the user select the low power mode from which the device will wake-up when the AST Alarm triggers.

Main Files

  • ast.c: Asynchronous Timer driver
  • ast.h: Asynchronous Timer driver header file
  • ast_example2.c: Asynchronous Timer example application using AST wakeup and BPM sleep function.

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:
    * -- -- AST Example 2 in Counter Mode --
    * -- xxxxxx-xx
    * -- Compiled: xxx xx xxxx xx:xx:xx --
    *
    * Config AST with 32kHz oscillator.
    * Use alarm0 to wakeup from low power mode.
    *
    * Menu :
    * -- Select low power mode:
    * 1: Sleep mode 0
    * 2: Sleep mode 1
    * 3: Sleep mode 2
    * 4: Sleep mode 3
    * 5: Wait mode
    * 6: Retention mode
    * 7: Backup mode