clock_masking_example.c File Reference


Detailed Description

Clock masking example for the AVR32 UC3.

Author:
Atmel Corporation: http://www.atmel.com
Support and FAQ: http://support.atmel.no/

Definition in file clock_masking_example.c.

#include <avr32/io.h>
#include "board.h"
#include "pm.h"
#include "gpio.h"

Include dependency graph for clock_masking_example.c:

Go to the source code of this file.

Defines

#define CLOCK_DIV_OFF   0
#define CLOCK_DIV_ON   1
#define DIV_FOURTH   1
#define DIV_HALF   0

Functions

int main (void)
 main function : Disable/enable module clocks according to pressed button


Define Documentation

#define CLOCK_DIV_OFF   0

Definition at line 89 of file clock_masking_example.c.

Referenced by main().

#define CLOCK_DIV_ON   1

Introduction

This example demonstrates the clock masking feature of AVR32 devices. Operating mode: Press button 0 to enable all clocks in the clock mask Press button 1 to disable all clocks on the PBB bus Press button 2 to turn off all modules on PBA exept PM/RTC/EIC and GPIO because we need them to enable the modules again (PM) and to signal the state with LEDs.

The LED signal following situations: LED0 = PBB clocks are active LED1 = All modules on PBA are clocked

Main Files

Compilation Information

This software is written for GNU GCC for AVR32 and for IAR Embedded Workbench for Atmel AVR32. Other compilers may or may not work.

Device Information

All AVR32 devices with GPIO controller.

Configuration Information

This example has been tested with the following configuration:

Contact Information

For further information, visit Atmel AVR32.
Support and FAQ: http://support.atmel.no/

Definition at line 88 of file clock_masking_example.c.

Referenced by main().

#define DIV_FOURTH   1

Definition at line 91 of file clock_masking_example.c.

Referenced by main().

#define DIV_HALF   0

Definition at line 90 of file clock_masking_example.c.

Referenced by main().


Function Documentation

int main ( void   ) 

main function : Disable/enable module clocks according to pressed button

Definition at line 96 of file clock_masking_example.c.

References FOSC0, gpio_clr_gpio_pin(), gpio_get_pin_value(), GPIO_PUSH_BUTTON_0, GPIO_PUSH_BUTTON_1, GPIO_PUSH_BUTTON_2, gpio_set_gpio_pin(), LED0_GPIO, LED1_GPIO, OSC0_STARTUP, and pm_switch_to_osc0().

00096                {
00097         volatile avr32_pm_t *pm = &AVR32_PM;
00098         
00099         // set synchronous clock source to external oscillator 0
00100         pm_switch_to_osc0(&AVR32_PM, FOSC0, OSC0_STARTUP);
00101         
00102         gpio_clr_gpio_pin(LED0_GPIO);
00103         gpio_clr_gpio_pin(LED1_GPIO);
00104         
00105         while(1){
00106                 
00107                 if(gpio_get_pin_value(GPIO_PUSH_BUTTON_0) == 0) {
00108                         // enable all module clocks on the different clock domains
00109                         pm->cpumask = 0xFFFFFFFF;
00110                         pm->hsbmask = 0xFFFFFFFF;
00111                         pm->pbamask = 0xFFFFFFFF;
00112                         pm->pbbmask = 0xFFFFFFFF;
00113                         
00114                         // Wait for ckrdy bit. Actually not needed here because no write or
00115                         // read action is performed to any module which clock was disabled
00116                         // before. 
00117                         while (!(pm->poscsr & AVR32_PM_POSCSR_CKRDY_MASK));
00118                         
00119                         gpio_clr_gpio_pin(LED0_GPIO);
00120                         gpio_clr_gpio_pin(LED1_GPIO);
00121                 }
00122                 if(gpio_get_pin_value(GPIO_PUSH_BUTTON_1) == 0){
00123                         // turn off all modules on PBB
00124                         pm->pbbmask = 0x0;
00125                         gpio_set_gpio_pin(LED0_GPIO);
00126                 }
00127                 if(gpio_get_pin_value(GPIO_PUSH_BUTTON_2) == 0){
00128                         // turn off all modules on PBA exept PM/RTC/EIC and GPIO
00129                         // because we need them to enable the modules again (PM) and to signal
00130                         // the state withe LEDs
00131                         pm->pbamask = 0x0000000A;
00132                         gpio_set_gpio_pin(LED1_GPIO);
00133                 }
00134                                 
00135         }
00136         return 0;
00137 }

Here is the call graph for this function:


Generated on Wed May 7 14:40:10 2008 for AVR32114 Using the AVR32 LCD Controller by  doxygen 1.5.3-20071008