Microchip® Advanced Software Framework

pmc_clock_switching_example.c File Reference

PMC Clock Switching example for SAM.

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

#include "asf.h"
#include "stdio_serial.h"
#include "conf_board.h"
#include "conf_pmc_clock_switching_example.h"

Macros

#define GCLK_ID   PMC_PCK_0
 Programmable Clock ID for the example by default. More...
 
#define GCLK_PIN   PIN_PCK0
 Programmable Clock Pin for the example by default. More...
 
#define GCLK_PIN_MUX   PIN_PCK0_MUX
 Programmable Clock Pin Mux for the example by default. More...
 
#define PMC_CLOCK_SWITCHING_EXAMPLE_BAUDRATE   (2400)
 PMC External Xtal 12Mhz. More...
 
#define PMC_CLOCK_SWITCHING_EXAMPLE_FIXED_PLLA   (128000000)
 Fixed PLLA test clock, 128Mhz. More...
 
#define PMC_PCK_PRES_CLK_1   PMC_PCK_PRES(0)
 
#define PMC_PCK_PRES_CLK_16   PMC_PCK_PRES(4)
 
#define PMC_PCK_PRES_CLK_2   PMC_PCK_PRES(1)
 
#define PMC_PCK_PRES_CLK_32   PMC_PCK_PRES(5)
 
#define PMC_PCK_PRES_CLK_4   PMC_PCK_PRES(2)
 
#define PMC_PCK_PRES_CLK_64   PMC_PCK_PRES(6)
 
#define PMC_PCK_PRES_CLK_8   PMC_PCK_PRES(3)
 
#define STRING_EOL   "\r"
 
#define STRING_HEADER
 

Functions

static void button1_handler (uint32_t ul_id, uint32_t ul_mask)
 Handler for Button 1 rising edge interrupt. More...
 
static void config_uart_and_pck (uint32_t ul_clock_source, uint32_t ul_prescaler, uint32_t ul_master_clock)
 Configure UART with the given master clock, and Configure PCK with the given divider source of master clock and prescaler. More...
 
static void configure_buttons (void)
 Configure the Push buttons. More...
 
static void configure_console (void)
 Configure the Console Uart. More...
 
int main (void)
 Application entry point for pmc_clock switch example. More...
 

Variables

static volatile uint8_t gs_uc_wait_button = 0
 User push button activated flag. More...
 

#define GCLK_ID   PMC_PCK_0

Programmable Clock ID for the example by default.

Referenced by config_uart_and_pck().

#define GCLK_PIN   PIN_PCK0

Programmable Clock Pin for the example by default.

Referenced by main().

#define GCLK_PIN_MUX   PIN_PCK0_MUX

Programmable Clock Pin Mux for the example by default.

Referenced by main().

#define PMC_CLOCK_SWITCHING_EXAMPLE_BAUDRATE   (2400)

PMC External Xtal 12Mhz.

Referenced by config_uart_and_pck().

#define PMC_CLOCK_SWITCHING_EXAMPLE_FIXED_PLLA   (128000000)

Fixed PLLA test clock, 128Mhz.

Referenced by main().

#define PMC_PCK_PRES_CLK_1   PMC_PCK_PRES(0)
#define PMC_PCK_PRES_CLK_16   PMC_PCK_PRES(4)

Referenced by main().

#define PMC_PCK_PRES_CLK_2   PMC_PCK_PRES(1)

Referenced by main().

#define PMC_PCK_PRES_CLK_32   PMC_PCK_PRES(5)
#define PMC_PCK_PRES_CLK_4   PMC_PCK_PRES(2)

Referenced by capture_init().

#define PMC_PCK_PRES_CLK_64   PMC_PCK_PRES(6)
#define PMC_PCK_PRES_CLK_8   PMC_PCK_PRES(3)
#define STRING_EOL   "\r"
#define STRING_HEADER
Value:
"-- Pmc Clock Switching Example --\r\n" \
"-- "BOARD_NAME" --\r\n" \
"-- Compiled: "__DATE__" "__TIME__" --"STRING_EOL
#define BOARD_NAME
Definition: inc/app_init.h:140
#define STRING_EOL
Definition: pmc_clock_switching_example.c:113

Referenced by main().

static void button1_handler ( uint32_t  ul_id,
uint32_t  ul_mask 
)
static

Handler for Button 1 rising edge interrupt.

Handle process led1 status change.

References gs_uc_wait_button.

Referenced by configure_buttons().

static void config_uart_and_pck ( uint32_t  ul_clock_source,
uint32_t  ul_prescaler,
uint32_t  ul_master_clock 
)
static

Configure UART with the given master clock, and Configure PCK with the given divider source of master clock and prescaler.

Parameters
ul_clock_sourceThe master clock divider source.
ul_prescalerMaster Clock prescaler.
ul_master_clockFrequency of the master clock (in Hz).

References sam_usart_opt_t::baudrate, BOARD_FREQ_SLCK_XTAL, sam_usart_opt_t::channel_mode, sam_usart_opt_t::char_length, CONF_UART_CHAR_LENGTH, CONF_UART_PARITY, CONF_UART_STOP_BITS, GCLK_ID, sam_usart_opt_t::parity_type, PMC_CLOCK_SWITCHING_EXAMPLE_BAUDRATE, pmc_disable_pck(), pmc_enable_pck(), pmc_enable_periph_clk(), pmc_switch_pck_to_mainck(), pmc_switch_pck_to_pllack(), pmc_switch_pck_to_sclk(), sam_usart_opt_t::stop_bits, uart_init(), usart_enable_rx(), usart_enable_tx(), and usart_init_rs232().

Referenced by main().

static void configure_buttons ( void  )
static

Configure the Push buttons.

Configure the PIO as inputs and generate corresponding interrupt when pressed or released.

References button1_handler(), pio_enable_interrupt(), pio_set_debounce_filter(), and pmc_enable_periph_clk().

Referenced by main().

static void configure_console ( void  )
static

volatile uint8_t gs_uc_wait_button = 0
static

User push button activated flag.

Referenced by button1_handler(), and main().