Microchip® Advanced Software Framework

uc3l/sysclk.h File Reference

Chip-specific system clock management functions.

Copyright (c) 2009-2018 Microchip Technology Inc. and its subsidiaries.

#include <board.h>
#include <avr32/io.h>
#include <dfll.h>
#include <osc.h>

Macros

#define AVR32_ACIFB_CLK_PBA   86
 
#define AVR32_ADCIFB_CLK_PBA   85
 
#define AVR32_AW_ADDRESS   0xFFFF7000
 
#define AVR32_AW_CLK_PBA   89
 
#define AVR32_CAT_CLK_PBA   87
 
#define AVR32_CORE_CLK_CPU_COUNT   16
 
#define AVR32_GLOC_CLK_PBA   88
 
#define AVR32_TC1_CLK_PBA   84
 
#define CONFIG_SYSCLK_CPU_DIV   0
 Configuration symbol for dividing the CPU clock frequency by \(2^{CONFIG\_SYSCLK\_CPU\_DIV}\). More...
 
#define CONFIG_SYSCLK_INIT_CPUMASK
 Configuration symbol for the CPU clocks enabled at power-on after the sysclock module has been initialized. More...
 
#define CONFIG_SYSCLK_INIT_HSBMASK
 Configuration symbol for the HSB clocks enabled at power-on after the sysclock module has been initialized. More...
 
#define CONFIG_SYSCLK_INIT_PBAMASK
 Configuration symbol for the PBA clocks enabled at power-on after the sysclock module has been initialized. More...
 
#define CONFIG_SYSCLK_INIT_PBBMASK
 Configuration symbol for the PBB clocks enabled at power-on after the sysclock module has been initialized. More...
 
#define CONFIG_SYSCLK_PBA_DIV   0
 Configuration symbol for dividing the PBA clock frequency by \(2^{CONFIG\_SYSCLK\_PBA\_DIV}\). More...
 
#define CONFIG_SYSCLK_PBB_DIV   0
 Configuration symbol for dividing the PBB clock frequency by \(2^{CONFIG\_SYSCLK\_PBB\_DIV}\). More...
 
System clock source
#define SYSCLK_SRC_RCSYS   AVR32_PM_MCSEL_SLOW
 System RC oscillator. More...
 
#define SYSCLK_SRC_OSC0   AVR32_PM_MCSEL_OSC0
 Oscillator 0. More...
 
#define SYSCLK_SRC_DFLL   AVR32_PM_MCSEL_DFLL0
 Digital Frequency Locked Loop. More...
 
#define SYSCLK_SRC_RC120M   AVR32_PM_MCSEL_RC120M
 120 MHz RC oscillator More...
 
Clocks derived from the CPU clock
#define SYSCLK_OCD   AVR32_OCD_CLK_CPU
 On-Chip Debug system. More...
 
#define SYSCLK_SYSTIMER   AVR32_CORE_CLK_CPU_COUNT
 COUNT/COMPARE registers. More...
 
Clocks derived from the HSB clock
#define SYSCLK_PDCA_HSB   (AVR32_PDCA_CLK_HSB % 32)
 PDCA memory interface. More...
 
#define SYSCLK_FLASHCDW_DATA   (AVR32_FLASHCDW_CLK_HSB % 32)
 Flash data interface. More...
 
#define SYSCLK_SAU_HSB   (AVR32_SAU_CLK_HSB % 32)
 Secure Access Unit HSB interface. More...
 
#define SYSCLK_PBA_BRIDGE   (AVR32_HMATRIX_CLK_HSB_PBA_BRIDGE % 32)
 HSB<->PBA bridge. More...
 
#define SYSCLK_PBB_BRIDGE   (AVR32_HMATRIX_CLK_HSB_PBB_BRIDGE % 32)
 HSB<->PBB bridge. More...
 
#define SYSCLK_EVENT   (AVR32_PES_CLK_HSB % 32)
 Peripheral Event System. More...
 
Clocks derived from the PBA clock
#define SYSCLK_PDCA_PB   (AVR32_PDCA_CLK_PBA % 32)
 PDCA peripheral bus interface. More...
 
#define SYSCLK_INTC   (AVR32_INTC_CLK_PBA % 32)
 Internal interrupt controller. More...
 
#define SYSCLK_PM   (AVR32_PM_CLK_PBA % 32)
 PM/RTC/EIM configuration. More...
 
#define SYSCLK_SCIF   (AVR32_SCIF_CLK_PBA % 32)
 System Control Interface. More...
 
#define SYSCLK_AST   (AVR32_AST_CLK_PBA % 32)
 Asynchronous Timer. More...
 
#define SYSCLK_WDT   (AVR32_WDT_CLK_PBA % 32)
 Watchdog Timer. More...
 
#define SYSCLK_EIC   (AVR32_EIC_CLK_PBA % 32)
 External Interrupt Controller. More...
 
#define SYSCLK_FREQM   (AVR32_FREQM_CLK_PBA % 32)
 Frequency Meter. More...
 
#define SYSCLK_GPIO   (AVR32_GPIO_CLK_PBA % 32)
 General-Purpose I/O. More...
 
#define SYSCLK_USART0   (AVR32_USART0_CLK_PBA % 32)
 USART 0. More...
 
#define SYSCLK_USART1   (AVR32_USART1_CLK_PBA % 32)
 USART 1. More...
 
#define SYSCLK_USART2   (AVR32_USART2_CLK_PBA % 32)
 USART 2. More...
 
#define SYSCLK_USART3   (AVR32_USART3_CLK_PBA % 32)
 USART 3. More...
 
#define SYSCLK_SPI   (AVR32_SPI_CLK_PBA % 32)
 SPI Controller. More...
 
#define SYSCLK_TWIM0   (AVR32_TWIM0_CLK_PBA % 32)
 TWI Master 0. More...
 
#define SYSCLK_TWIM1   (AVR32_TWIM1_CLK_PBA % 32)
 TWI Master 1. More...
 
#define SYSCLK_TWIS0   (AVR32_TWIS0_CLK_PBA % 32)
 TWI Slave 0. More...
 
#define SYSCLK_TWIS1   (AVR32_TWIS1_CLK_PBA % 32)
 TWI Slave 1. More...
 
#define SYSCLK_PWMA   (AVR32_PWMA_CLK_PBA % 32)
 Pulse Width Modulator. More...
 
#define SYSCLK_TC0   (AVR32_TC0_CLK_PBA % 32)
 Timer/Counter 0. More...
 
#define SYSCLK_TC1   (AVR32_TC1_CLK_PBA % 32)
 Timer/Counter 1. More...
 
#define SYSCLK_ADCIFB   (AVR32_ADCIFB_CLK_PBA % 32)
 A/D Converter. More...
 
#define SYSCLK_ACIFB   (AVR32_ACIFB_CLK_PBA % 32)
 Analog Comparator. More...
 
#define SYSCLK_CAT   (AVR32_CAT_CLK_PBA % 32)
 Capacitive Touch. More...
 
#define SYSCLK_GLOC   (AVR32_GLOC_CLK_PBA % 32)
 Glue Logic Controller. More...
 
#define SYSCLK_AW   (AVR32_AW_CLK_PBA % 32)
 aWire UART More...
 
Clocks derived from the PBB clock
#define SYSCLK_FLASHCDW_REGS   (AVR32_FLASHC_CLK_PBB % 32)
 Flash Controller registers. More...
 
#define SYSCLK_HMATRIX   (AVR32_HMATRIX_CLK_PBB % 32)
 HSB Matrix configuration. More...
 
#define SYSCLK_SAU_REGS   (AVR32_SAU_CLK_PBB % 32)
 Secure Access Unit register. More...
 
Example Configuration
#define CONFIG_SYSCLK_SOURCE   SYSCLK_SRC_RCSYS
 Clock source to use. More...
 

Functions

void sysclk_priv_disable_module (unsigned int bus_id, unsigned int module_index)
 Disable a maskable module clock. More...
 
void sysclk_priv_enable_module (unsigned int bus_id, unsigned int module_index)
 Enable a maskable module clock. More...
 
Querying the system clock and its derived clocks

The following functions may be used to query the current frequency of the system clock and the CPU and bus clocks derived from it.

sysclk_get_main_hz() and sysclk_get_cpu_hz() can be assumed to be available on all platforms, although some platforms may define additional accessors for various chip-internal bus clocks. These are usually not intended to be queried directly by generic code.

static uint32_t sysclk_get_main_hz (void)
 Return the current rate in Hz of the main system clock. More...
 
static uint32_t sysclk_get_cpu_hz (void)
 Return the current rate in Hz of the CPU clock. More...
 
static uint32_t sysclk_get_hsb_hz (void)
 Return the current rate in Hz of the High-Speed Bus clock. More...
 
static uint32_t sysclk_get_pba_hz (void)
 Return the current rate in Hz of the Peripheral Bus A clock. More...
 
static uint32_t sysclk_get_pbb_hz (void)
 Return the current rate in Hz of the Peripheral Bus B clock. More...
 
static uint32_t sysclk_get_peripheral_bus_hz (const volatile void *module)
 Retrieves the current rate in Hz of the Peripheral Bus clock attached to the specified peripheral. More...
 
Enabling and disabling synchronous clocks
static void sysclk_enable_cpu_module (unsigned int index)
 Enable a module clock derived from the CPU clock. More...
 
static void sysclk_disable_cpu_module (unsigned int index)
 Disable a module clock derived from the CPU clock. More...
 
static void sysclk_enable_hsb_module (unsigned int index)
 Enable a module clock derived from the HSB clock. More...
 
static void sysclk_disable_hsb_module (unsigned int index)
 Disable a module clock derived from the HSB clock. More...
 
static void sysclk_enable_pba_module (unsigned int index)
 Enable a module clock derived from the PBA clock. More...
 
static void sysclk_disable_pba_module (unsigned int index)
 Disable a module clock derived from the PBA clock. More...
 
void sysclk_enable_pbb_module (unsigned int index)
 Enable a module clock derived from the PBB clock. More...
 
void sysclk_disable_pbb_module (unsigned int index)
 Disable a module clock derived from the PBB clock. More...
 
static void sysclk_enable_peripheral_clock (const volatile void *module)
 Enable a peripheral's clock from its base address. More...
 
static void sysclk_disable_peripheral_clock (const volatile void *module)
 Disable a peripheral's clock from its base address. More...
 
System Clock Source and Prescaler configuration
void sysclk_set_prescalers (unsigned int cpu_shift, unsigned int pba_shift, unsigned int pbb_shift)
 Set system clock prescaler configuration. More...
 
void sysclk_set_source (uint_fast8_t src)
 Change the source of the main system clock. More...
 
System Clock Initialization
void sysclk_init (void)
 Initialize the synchronous clock system. More...
 

#define AVR32_ACIFB_CLK_PBA   86
#define AVR32_ADCIFB_CLK_PBA   85
#define AVR32_AW_ADDRESS   0xFFFF7000
#define AVR32_AW_CLK_PBA   89
#define AVR32_CAT_CLK_PBA   87
#define AVR32_CORE_CLK_CPU_COUNT   16
#define AVR32_GLOC_CLK_PBA   88
#define AVR32_TC1_CLK_PBA   84