Atmel Software Framework

System Clock internals

System clock management is fairly straightforward apart from one thing: Enabling and disabling bus bridges. When all peripherals on a given bus are disabled, the bridge to the bus may be disabled. Only the PBA, PBB and PBC busses support this, and it is not practical to disable the PBA bridge as it includes the Power Manager, so turning it off would make it impossible to turn anything back on again. Also, PBB and PBC share the same MASK register (with the AES module being the only peripheral on the PBC.)

The system clock implementation keeps track of a reference count for PBB and PBC. When the reference count is zero, the bus bridge is disabled, otherwise it is enabled.

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...
 

Variables

static uint8_t sysclk_bus_refcount [2]
 Number of enabled peripherals on the PBB and PBC busses. More...
 

Initial module clock masks

These are the mask values written to the xxxMASK registers during initialization if the user has overridden the default behavior of all clocks left enabled. These values assume that:

  • Debugging should be possible
  • The program may be running from flash
  • The PM should be available to unmask other clocks
  • All on-chip RAM should be available
  • INTC, PM and GPIO are made permanently available for now; this may change in the future.
#define SYSCLK_INIT_MINIMAL_CPUMASK
 Initial value of CPUMASK. More...
 
#define SYSCLK_HSBMASK_STICKYBITS   (0x00000800)
 Sticky Bits in HSBMASK according to the datasheet. More...
 
#define SYSCLK_INIT_MINIMAL_HSBMASK
 Initial value of HSBMASK. More...
 
#define SYSCLK_PBAMASK_STICKYBITS   (0x00180000)
 Sticky Bits in PBAMASK according to the datasheet. More...
 
#define SYSCLK_INIT_MINIMAL_PBAMASK
 Initial value of PBAMASK. More...
 
#define SYSCLK_INIT_MINIMAL_PBBMASK   0
 Initial value of PBBMASK. More...
 

#define SYSCLK_HSBMASK_STICKYBITS   (0x00000800)

Sticky Bits in HSBMASK according to the datasheet.

#define SYSCLK_INIT_MINIMAL_CPUMASK
Value:
((1 << SYSCLK_OCD) \
| (1 << SYSCLK_SYSTIMER))
#define SYSCLK_OCD
On-Chip Debug system.
Definition: uc3a3_a4/sysclk.h:232
#define SYSCLK_SYSTIMER
COUNT/COMPARE system registers.
Definition: uc3a3_a4/sysclk.h:234

Initial value of CPUMASK.

Referenced by sysclk_init().

#define SYSCLK_INIT_MINIMAL_HSBMASK
Value:
| (1 << SYSCLK_PBA_BRIDGE) \
| (1 << SYSCLK_HRAMC0) \
| (1 << SYSCLK_HRAMC1) \
#define SYSCLK_FLASHC_DATA
Flash data interface.
Definition: uc3a3_a4/sysclk.h:240
#define SYSCLK_HRAMC1
HSB RAM block 1.
Definition: uc3a3_a4/sysclk.h:260
#define SYSCLK_PBA_BRIDGE
HSB<->PBA bridge.
Definition: uc3a3_a4/sysclk.h:242
#define SYSCLK_HSBMASK_STICKYBITS
Sticky Bits in HSBMASK according to the datasheet.
Definition: sysclk.c:106
#define SYSCLK_HRAMC0
HSB RAM block 0.
Definition: uc3a3_a4/sysclk.h:258

Initial value of HSBMASK.

Referenced by sysclk_init().

#define SYSCLK_INIT_MINIMAL_PBAMASK
Value:
((1 << SYSCLK_INTC) \
| (1 << SYSCLK_GPIO) \
| (1 << SYSCLK_PM) \
#define SYSCLK_PM
PM/RTC/EIM configuration.
Definition: uc3a3_a4/sysclk.h:272
#define SYSCLK_PBAMASK_STICKYBITS
Sticky Bits in PBAMASK according to the datasheet.
Definition: sysclk.c:118
#define SYSCLK_INTC
Internal interrupt controller.
Definition: uc3a3_a4/sysclk.h:266
#define SYSCLK_GPIO
General-Purpose I/O.
Definition: uc3a3_a4/sysclk.h:268

Initial value of PBAMASK.

Referenced by sysclk_init().

#define SYSCLK_INIT_MINIMAL_PBBMASK   0

Initial value of PBBMASK.

Referenced by sysclk_init().

#define SYSCLK_PBAMASK_STICKYBITS   (0x00180000)

Sticky Bits in PBAMASK according to the datasheet.

void sysclk_priv_disable_module ( unsigned int  bus_id,
unsigned int  module_index 
)

Disable a maskable module clock.

Parameters
bus_idBus index, given by the AVR32_PM_CLK_GRP_xxx definitions.
module_indexIndex of the module to be disabled. This is the bit number in the corresponding xxxMASK register.

References cpu_irq_restore(), and cpu_irq_save().

Referenced by sysclk_disable_cpu_module(), sysclk_disable_hsb_module(), sysclk_disable_pba_module(), sysclk_disable_pbb_module(), and sysclk_get_peripheral_bus_hz().

void sysclk_priv_enable_module ( unsigned int  bus_id,
unsigned int  module_index 
)

Enable a maskable module clock.

Parameters
bus_idBus index, given by the AVR32_PM_CLK_GRP_xxx definitions.
module_indexIndex of the module to be enabled. This is the bit number in the corresponding xxxMASK register.

References cpu_irq_restore(), and cpu_irq_save().

Referenced by sysclk_enable_cpu_module(), sysclk_enable_hsb_module(), sysclk_enable_pba_module(), sysclk_enable_pbb_module(), and sysclk_get_peripheral_bus_hz().

uint8_t sysclk_bus_refcount[2]
static

Number of enabled peripherals on the PBB and PBC busses.

Referenced by sysclk_disable_pbb_module(), and sysclk_enable_pbb_module().