Definition in file scif_example3.c.
#include "board.h"
#include "gpio.h"
#include "scif_uc3l.h"
#include "power_clocks_lib.h"
Go to the source code of this file.
Defines | |
Generic Clock Configuration | |
#define | EXAMPLE_GCLK_FUNCTION AVR32_SCIF_GCLK_1_0_FUNCTION |
#define | EXAMPLE_GCLK_ID AVR32_SCIF_GCLK_DFLL0_SSG |
#define | EXAMPLE_GCLK_PIN AVR32_SCIF_GCLK_1_0_PIN |
Functions | |
static void | local_start_gc () |
Set-up a generic clock at 44kz with the DFLL as a source, output the generic clock to a pin. | |
int | main (void) |
#define EXAMPLE_GCLK_FUNCTION AVR32_SCIF_GCLK_1_0_FUNCTION |
#define EXAMPLE_GCLK_ID AVR32_SCIF_GCLK_DFLL0_SSG |
#define EXAMPLE_GCLK_PIN AVR32_SCIF_GCLK_1_0_PIN |
static void local_start_gc | ( | ) | [static] |
Set-up a generic clock at 44kz with the DFLL as a source, output the generic clock to a pin.
Definition at line 112 of file scif_example3.c.
References EXAMPLE_GCLK_FUNCTION, EXAMPLE_GCLK_ID, EXAMPLE_GCLK_PIN, SCIF_GCCTRL_OSC32K, and scif_start_gclk().
Referenced by main().
00113 { 00114 scif_gclk_opt_t gclkOpt = {SCIF_GCCTRL_OSC32K, 0, 0}; 00115 volatile int i; 00116 00117 00118 if(scif_start_gclk(EXAMPLE_GCLK_ID, &gclkOpt)) 00119 { // Error 00120 while(1) 00121 { 00122 gpio_tgl_gpio_pin(LED3_GPIO); 00123 for(i=1000; i; i--); 00124 } 00125 } 00126 00127 // Assign a GPIO to generic clock output 00128 gpio_enable_module_pin(EXAMPLE_GCLK_PIN, EXAMPLE_GCLK_FUNCTION); 00129 // Note that gclk1 is GPIO pin 6 pa06 on AT32UC3L064 pin 10 on QFP48. 00130 }
int main | ( | void | ) |
OSC32K config.
Definition at line 143 of file scif_example3.c.
References local_start_gc(), SCIF_OSC_MODE_2PIN_CRYSTAL_HICUR, and scif_start_osc32().
00144 { 00146 scif_osc32_opt_t osc32Conf = { 00147 SCIF_OSC_MODE_2PIN_CRYSTAL_HICUR, // 2-pin Crystal and high current mode. Crystal is connected to XIN32/XOUT32. 00148 OSC32_STARTUP, // oscillator startup time 00149 true, // select the alternate xin32_2 and xout32_2 for the 32kHz crystal oscillator 00150 false, // disable the 1kHz output 00151 true // enable the 32kHz output 00152 }; 00153 volatile int i,j; 00154 00155 // - configure and start the OSC32K 32kHz oscillator, 00156 if(PASS != scif_start_osc32(&osc32Conf, true)) 00157 { // Error 00158 while(1) 00159 { 00160 gpio_tgl_gpio_pin(LED3_GPIO); 00161 for(i=1000; i; i--); 00162 } 00163 } 00164 00165 // - set-up a generic clock at 32kHz with the OSC32K osc as a source, 00166 // - output the generic clock to a pin. 00167 local_start_gc(); 00168 00169 // - toggle all four leds 10 times, 00170 for(i=25;i;i--) 00171 { 00172 gpio_tgl_gpio_pin(LED0_GPIO); gpio_tgl_gpio_pin(LED1_GPIO); 00173 gpio_tgl_gpio_pin(LED2_GPIO); gpio_tgl_gpio_pin(LED3_GPIO); 00174 for(j=1000;j;j--); 00175 } 00176 00177 // - then switch the device into the static sleep mode (while still maintaining 00178 // the OSC32 32kHz oscillator). 00179 00180 // If there is a chance that any PB write operations are incomplete, the CPU 00181 // should perform a read operation from any register on the PB bus before 00182 // executing the sleep instruction. 00183 AVR32_INTC.ipr[0]; // Dummy read 00184 00185 pm_sleep(AVR32_PM_SMODE_STATIC); 00186 // Note: in static sleep mode, the GCLK output is not maintained but the OSC32K 00187 // oscillator is still active (check the XIN32_2 pin (500mv peek-to-peek amplitude)). 00188 00189 while(1); 00190 }