This group contains functions and definitions related to configuring and enabling/disabling on-chip oscillators.
Internal RC-oscillators, external crystal oscillators and external clock generators are supported by this module. What all of these have in common is that they swing at a fixed, nominal frequency which is normally not adjustable.
The following example demonstrates how to enable the external oscillator on XMEGA A and wait for it to be ready to use. The oscillator identifiers are platform-specific, so while the same procedure is used on all platforms, the parameter to osc_enable() will be different from device to device.
If external oscillators are used, the board code must provide the following definitions for each of those:
Functions | |
static void | osc_disable (uint32_t ul_id) |
static void | osc_enable (uint32_t ul_id) |
static uint32_t | osc_get_rate (uint32_t ul_id) |
static bool | osc_is_ready (uint32_t ul_id) |
Oscillator Management | |
static void | osc_wait_ready (uint8_t id) |
Wait until the oscillator identified by id is ready. More... | |
Oscillator identifiers | |
#define | OSC_SLCK_32K_RC 0 |
Internal 32kHz RC oscillator. More... | |
#define | OSC_SLCK_32K_XTAL 1 |
External 32kHz crystal oscillator. More... | |
#define | OSC_SLCK_32K_BYPASS 2 |
External 32kHz bypass oscillator. More... | |
#define | OSC_MAINCK_4M_RC 3 |
Internal 4MHz RC oscillator. More... | |
#define | OSC_MAINCK_8M_RC 4 |
Internal 8MHz RC oscillator. More... | |
#define | OSC_MAINCK_12M_RC 5 |
Internal 12MHz RC oscillator. More... | |
#define | OSC_MAINCK_XTAL 6 |
External crystal oscillator. More... | |
#define | OSC_MAINCK_BYPASS 7 |
External bypass oscillator. More... | |
Oscillator clock speed in hertz | |
#define | OSC_SLCK_32K_RC_HZ CHIP_FREQ_SLCK_RC |
Internal 32kHz RC oscillator. More... | |
#define | OSC_SLCK_32K_XTAL_HZ BOARD_FREQ_SLCK_XTAL |
External 32kHz crystal oscillator. More... | |
#define | OSC_SLCK_32K_BYPASS_HZ BOARD_FREQ_SLCK_BYPASS |
External 32kHz bypass oscillator. More... | |
#define | OSC_MAINCK_4M_RC_HZ CHIP_FREQ_MAINCK_RC_4MHZ |
Internal 4MHz RC oscillator. More... | |
#define | OSC_MAINCK_8M_RC_HZ CHIP_FREQ_MAINCK_RC_8MHZ |
Internal 8MHz RC oscillator. More... | |
#define | OSC_MAINCK_12M_RC_HZ CHIP_FREQ_MAINCK_RC_12MHZ |
Internal 12MHz RC oscillator. More... | |
#define | OSC_MAINCK_XTAL_HZ BOARD_FREQ_MAINCK_XTAL |
External crystal oscillator. More... | |
#define | OSC_MAINCK_BYPASS_HZ BOARD_FREQ_MAINCK_BYPASS |
External bypass oscillator. More... | |
#define OSC_MAINCK_12M_RC 5 |
Internal 12MHz RC oscillator.
Referenced by genclk_enable_source(), osc_disable(), osc_enable(), osc_get_rate(), osc_is_ready(), and sysclk_init().
#define OSC_MAINCK_12M_RC_HZ CHIP_FREQ_MAINCK_RC_12MHZ |
Internal 12MHz RC oscillator.
Referenced by genclk_get_frequency_hz(), osc_get_rate(), and sysclk_get_main_hz().
#define OSC_MAINCK_4M_RC 3 |
Internal 4MHz RC oscillator.
Referenced by genclk_enable_source(), osc_disable(), osc_enable(), osc_get_rate(), and osc_is_ready().
#define OSC_MAINCK_4M_RC_HZ CHIP_FREQ_MAINCK_RC_4MHZ |
Internal 4MHz RC oscillator.
Referenced by genclk_get_frequency_hz(), osc_get_rate(), and sysclk_get_main_hz().
#define OSC_MAINCK_8M_RC 4 |
Internal 8MHz RC oscillator.
Referenced by genclk_enable_source(), main(), osc_disable(), osc_enable(), osc_get_rate(), osc_is_ready(), and sysclk_init().
#define OSC_MAINCK_8M_RC_HZ CHIP_FREQ_MAINCK_RC_8MHZ |
Internal 8MHz RC oscillator.
Referenced by genclk_get_frequency_hz(), osc_get_rate(), and sysclk_get_main_hz().
#define OSC_MAINCK_BYPASS 7 |
External bypass oscillator.
Referenced by genclk_enable_source(), osc_disable(), osc_enable(), osc_get_rate(), osc_is_ready(), and sysclk_init().
#define OSC_MAINCK_BYPASS_HZ BOARD_FREQ_MAINCK_BYPASS |
External bypass oscillator.
Referenced by sysclk_get_main_hz().
#define OSC_MAINCK_XTAL 6 |
External crystal oscillator.
Referenced by genclk_enable_source(), main(), osc_disable(), osc_enable(), osc_get_rate(), osc_is_ready(), and sysclk_init().
#define OSC_MAINCK_XTAL_HZ BOARD_FREQ_MAINCK_XTAL |
External crystal oscillator.
Referenced by genclk_get_frequency_hz(), and sysclk_get_main_hz().
#define OSC_SLCK_32K_BYPASS 2 |
External 32kHz bypass oscillator.
Referenced by genclk_enable_source(), osc_disable(), osc_enable(), osc_get_rate(), osc_is_ready(), and sysclk_init().
#define OSC_SLCK_32K_BYPASS_HZ BOARD_FREQ_SLCK_BYPASS |
External 32kHz bypass oscillator.
Referenced by sysclk_get_main_hz().
#define OSC_SLCK_32K_RC 0 |
Internal 32kHz RC oscillator.
Referenced by genclk_enable_source(), osc_disable(), osc_enable(), osc_get_rate(), osc_is_ready(), and sysclk_init().
#define OSC_SLCK_32K_RC_HZ CHIP_FREQ_SLCK_RC |
Internal 32kHz RC oscillator.
Referenced by genclk_get_frequency_hz(), osc_enable(), osc_get_rate(), and sysclk_get_main_hz().
#define OSC_SLCK_32K_XTAL 1 |
External 32kHz crystal oscillator.
Referenced by genclk_enable_source(), osc_disable(), osc_enable(), osc_get_rate(), osc_is_ready(), and sysclk_init().
#define OSC_SLCK_32K_XTAL_HZ BOARD_FREQ_SLCK_XTAL |
External 32kHz crystal oscillator.
Referenced by genclk_get_frequency_hz(), and sysclk_get_main_hz().
|
inlinestatic |
References OSC_MAINCK_12M_RC, OSC_MAINCK_4M_RC, OSC_MAINCK_8M_RC, OSC_MAINCK_BYPASS, OSC_MAINCK_XTAL, OSC_SLCK_32K_BYPASS, OSC_SLCK_32K_RC, OSC_SLCK_32K_XTAL, PMC_OSC_BYPASS, pmc_osc_disable_fastrc(), pmc_osc_disable_xtal(), and PMC_OSC_XTAL.
Referenced by main().
|
inlinestatic |
References BOARD_OSC_STARTUP_US, OSC_MAINCK_12M_RC, OSC_MAINCK_4M_RC, OSC_MAINCK_8M_RC, OSC_MAINCK_BYPASS, OSC_MAINCK_XTAL, OSC_SLCK_32K_BYPASS, OSC_SLCK_32K_RC, OSC_SLCK_32K_RC_HZ, OSC_SLCK_32K_XTAL, PMC_OSC_BYPASS, PMC_OSC_XTAL, pmc_switch_mainck_to_fastrc(), pmc_switch_mainck_to_xtal(), pmc_switch_sclk_to_32kxtal(), and pmc_us_to_moscxtst.
Referenced by genclk_enable_source(), main(), pll_enable_source(), and sysclk_init().
|
inlinestatic |
References BOARD_FREQ_MAINCK_BYPASS, BOARD_FREQ_MAINCK_XTAL, BOARD_FREQ_SLCK_BYPASS, BOARD_FREQ_SLCK_XTAL, OSC_MAINCK_12M_RC, OSC_MAINCK_12M_RC_HZ, OSC_MAINCK_4M_RC, OSC_MAINCK_4M_RC_HZ, OSC_MAINCK_8M_RC, OSC_MAINCK_8M_RC_HZ, OSC_MAINCK_BYPASS, OSC_MAINCK_XTAL, OSC_SLCK_32K_BYPASS, OSC_SLCK_32K_RC, OSC_SLCK_32K_RC_HZ, and OSC_SLCK_32K_XTAL.
Referenced by pll_config_init().
|
inlinestatic |
References OSC_MAINCK_12M_RC, OSC_MAINCK_4M_RC, OSC_MAINCK_8M_RC, OSC_MAINCK_BYPASS, OSC_MAINCK_XTAL, OSC_SLCK_32K_BYPASS, OSC_SLCK_32K_RC, OSC_SLCK_32K_XTAL, pmc_osc_is_ready_32kxtal(), and pmc_osc_is_ready_mainck().
Referenced by genclk_enable_source(), and osc_wait_ready().
|
inlinestatic |
Wait until the oscillator identified by id is ready.
This function will busy-wait for the oscillator identified by id to become stable and ready to use as a clock source.
id | A number identifying the oscillator to wait for. |
References osc_is_ready().
Referenced by genclk_enable_source(), main(), pll_enable_source(), and sysclk_init().