Atmel Software Framework

uc3a0_a1/osc.h File Reference

Chip-specific oscillator management functions.

Copyright (c) 2010-2011 Atmel Corporation. All rights reserved.

#include <board.h>
#include <stdbool.h>
#include <stdint.h>
#include <avr32/io.h>

Macros

#define OSC0_MODE_VALUE   UNDEFINED
 Board-dependent value written to the MODE bitfield of PM_OSCCTRL(0) More...
 
#define OSC0_STARTUP_TIMEOUT   UNDEFINED
 Number of slow clock cycles to wait for OSC0 to start. More...
 
#define OSC0_STARTUP_VALUE   UNDEFINED
 Board-dependent value written to the STARTUP bitfield of PM_OSCCTRL(0) More...
 
#define OSC1_MODE_VALUE   UNDEFINED
 Board-dependent value written to the MODE bitfield of PM_OSCCTRL(1) More...
 
#define OSC1_STARTUP_TIMEOUT   UNDEFINED
 Number of slow clock cycles to wait for OSC1 to start. More...
 
#define OSC1_STARTUP_VALUE   UNDEFINED
 Board-dependent value written to the STARTUP bitfield of PM_OSCCTRL(1) More...
 
#define OSC32_MODE_VALUE   UNDEFINED
 
#define OSC32_STARTUP_TIMEOUT   UNDEFINED
 
#define OSC32_STARTUP_VALUE   UNDEFINED
 
Oscillator identifiers
#define OSC_ID_OSC0   0
 External Oscillator 0. More...
 
#define OSC_ID_OSC1   1
 External Oscillator 1. More...
 
#define OSC_ID_OSC32   2
 External 32 kHz oscillator. More...
 
OSC0/OSC1 mode values
#define OSC_MODE_EXTERNAL   AVR32_PM_MODE_EXT_CLOCK
 External clock connected to XIN. More...
 
#define OSC_MODE_XTAL_G0   AVR32_PM_MODE_CRYSTAL_G0
 Crystal connected to XIN/XOUT. Use oscillator gain G0 (400 kHz to 900 kHz) More...
 
#define OSC_MODE_XTAL_G1   AVR32_PM_MODE_CRYSTAL_G1
 Crystal connected to XIN/XOUT. Use oscillator gain G1 (900 kHz to 3 MHz) More...
 
#define OSC_MODE_XTAL_G2   AVR32_PM_MODE_CRYSTAL_G2
 Crystal connected to XIN/XOUT. Use oscillator gain G2 (3 MHz to 8 MHz) More...
 
#define OSC_MODE_XTAL_G3   AVR32_PM_MODE_CRYSTAL_G3
 Crystal connected to XIN/XOUT. Use oscillator gain G3 (8 MHz and higher) More...
 
OSC32 mode values
#define OSC32_MODE_EXTERNAL   AVR32_PM_OSCCTRL32_MODE_EXT_CLOCK
 External clock connected to XIN32. More...
 
#define OSC32_MODE_XTAL   AVR32_PM_OSCCTRL32_MODE_CRYSTAL
 Crystal connected to XIN32/XOUT32. Use automatic gain control. More...
 
OSC0/OSC1 startup values
#define OSC_STARTUP_0   AVR32_PM_OSCCTRL0_STARTUP_0_RCOSC
 0 cycles More...
 
#define OSC_STARTUP_64   AVR32_PM_OSCCTRL0_STARTUP_64_RCOSC
 64 cycles (560 us) More...
 
#define OSC_STARTUP_128   AVR32_PM_OSCCTRL0_STARTUP_128_RCOSC
 128 cycles (1.1 ms) More...
 
#define OSC_STARTUP_2048   AVR32_PM_OSCCTRL0_STARTUP_2048_RCOSC
 2048 cycles (18 ms) More...
 
#define OSC_STARTUP_4096   AVR32_PM_OSCCTRL0_STARTUP_4096_RCOSC
 4096 cycles (36 ms) More...
 
#define OSC_STARTUP_8192   AVR32_PM_OSCCTRL0_STARTUP_8192_RCOSC
 8192 cycles (71 ms) More...
 
#define OSC_STARTUP_16384   AVR32_PM_OSCCTRL0_STARTUP_16384_RCOSC
 16384 cycles (142 ms) More...
 
OSC32 startup values
#define OSC32_STARTUP_0   AVR32_PM_OSCCTRL32_STARTUP_0_RCOSC
 0 cycles More...
 
#define OSC32_STARTUP_128   AVR32_PM_OSCCTRL32_STARTUP_128_RCOSC
 128 cycles (1.1 ms) More...
 
#define OSC32_STARTUP_8192   AVR32_PM_OSCCTRL32_STARTUP_8192_RCOSC
 8192 cycles (72.3 ms) More...
 
#define OSC32_STARTUP_16384   AVR32_PM_OSCCTRL32_STARTUP_16384_RCOSC
 16384 cycles (143 ms) More...
 
#define OSC32_STARTUP_65536   AVR32_PM_OSCCTRL32_STARTUP_65536_RCOSC
 65536 cycles (570 ms) More...
 
#define OSC32_STARTUP_131072   AVR32_PM_OSCCTRL32_STARTUP_131072_RCOSC
 131072 cycles (1.1 s) More...
 
#define OSC32_STARTUP_262144   AVR32_PM_OSCCTRL32_STARTUP_262144_RCOSC
 262144 cycles (2.3 s) More...
 
#define OSC32_STARTUP_524288   AVR32_PM_OSCCTRL32_STARTUP_524288_RCOSC
 524288 cycles (4.6 s) More...
 
Board-specific configuration parameters

The following definitions must be provided by the board code for all working oscillators on the board.

#define BOARD_OSC0_HZ   UNDEFINED
 Clock frequency of OSC0 in Hz. More...
 
#define BOARD_OSC0_STARTUP_US   UNDEFINED
 Startup time of OSC0 in microseconds. More...
 
#define BOARD_OSC0_IS_XTAL   UNDEFINED
 OSC0 uses a crystal, not an external clock. More...
 
#define BOARD_OSC1_HZ   UNDEFINED
 Clock frequency of OSC1 in Hz. More...
 
#define BOARD_OSC1_STARTUP_US   UNDEFINED
 Startup time of OSC1 in microseconds. More...
 
#define BOARD_OSC1_IS_XTAL   UNDEFINED
 OSC1 uses a crystal, not an external clock. More...
 
#define BOARD_OSC32_HZ   UNDEFINED
 Clock frequency of OSC32 in Hz. More...
 
#define BOARD_OSC32_STARTUP_US   UNDEFINED
 Startup time of OSC32 in microseconds. More...
 
#define BOARD_OSC32_IS_XTAL   UNDEFINED
 OSC32 uses a crystal, not an external clock. More...
 
Slow clock frequency limits

The slow clock is an internal RC oscillator whose frequency may drift a bit as a result of temperature changes.

These definitions provide upper and lower limits which may be used to calculate upper and lower limits of timeouts, derived clock frequencies, etc.

#define OSC_SLOW_NOMINAL_HZ   AVR32_PM_RCOSC_FREQUENCY
 Nominal frequency of the slow clock in Hz. More...
 
#define OSC_SLOW_MIN_HZ   100000
 Minimum frequency of the slow clock in Hz. More...
 
#define OSC_SLOW_MAX_HZ   120000
 Maximum frequency of the slow clock in Hz. More...
 

Functions

Oscillator Management
static void osc_enable (uint8_t id)
 Enable oscillator id. More...
 
static void osc_disable (uint8_t id)
 Disable oscillator id. More...
 
static bool osc_is_ready (uint8_t id)
 Determine whether oscillator id is ready. More...
 
static uint32_t osc_get_rate (uint8_t id)
 Return the frequency of oscillator id in Hz. More...