Microchip® Advanced Software Framework

pwma_example2.c File Reference

Example to illustrate the Peripheral Event System in PWMA Module.

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

#include <asf.h>
#include "conf_example.h"

Functions

static void ac_init (void)
 Initializes and enables the ACIFB Module. More...
 
 ISR (acifb_irq, AVR32_ACIFB_IRQ_GROUP, EXAMPLE_ACIFB_INTERRUPT_PRIORITY)
 ACIFB ISR Routine. More...
 
int main (void)
 Main Application Routine
-Initialize the system clocks
Note: The clock should be configured in "conf_clock.h"
-Initialize the PWMA Module
-Read the TOP value
-Initialize the ACIFB Module
-Initialize the delay service with CPU frequency
-Enter into sleep mode
. More...
 
static void pwma_init (void)
 Initializes and enables the PWMA Module. More...
 

Variables

volatile avr32_acifb_t * acifb = &AVR32_ACIFB
 Global variable to Store the ACIFB module address. More...
 
volatile avr32_pwma_t * pwma = &AVR32_PWMA
 Global variable to Store the PWMA module address. More...
 
volatile uint16_t read_top_value = 0
 Variable to read the TOP value. More...
 

static void ac_init ( void  )
static

Initializes and enables the ACIFB Module.

Initialize the ACIFB Module with the User Triggered Mode
-Start the GCLK for ACIFB
-Configure and enable the ACIFB with user triggered mode
-Enable the positive event generation in ACIFB channel
-Enable and register the ACIFB interrupt
.

References acifb, acifb_channels_setup(), acifb_setup_and_enable(), cpu_irq_disable, cpu_irq_enable, div_ceil, acifb_channel_t::filter_len, genclk_enable_config(), gpio_enable_module(), irq_initialize_vectors, irq_register_handler, acifb_t::sut, and sysclk_get_pba_hz().

Referenced by main().

ISR ( acifb_irq  ,
AVR32_ACIFB_IRQ_GROUP  ,
EXAMPLE_ACIFB_INTERRUPT_PRIORITY   
)

ACIFB ISR Routine.

Parameters
acifb_irqISR Routine name
AVR32_ACIFB_IRQ_GROUPACIFB Interrupt Group
EXAMPLE_ACIFB_INTERRUPT_PRIORITYPriority level of the interrupt

References acifb, pwma, pwma_set_channels_value(), and read_top_value.

int main ( void  )

Main Application Routine
-Initialize the system clocks
Note: The clock should be configured in "conf_clock.h"
-Initialize the PWMA Module
-Read the TOP value
-Initialize the ACIFB Module
-Initialize the delay service with CPU frequency
-Enter into sleep mode
.

References ac_init(), delay_init, pm_sleep(), pwma, pwma_init(), read_top_value, sysclk_get_cpu_hz(), and sysclk_init().

static void pwma_init ( void  )
static

Initializes and enables the PWMA Module.

Initialize the PWMA Module -Start the GCLK for PWMA Module -Configure and Enable the PWMA Module -Load the duty cycle value -Enable the input peripheral event.

References delay_ms, div_ceil, ERROR_LED, EXAMPLE_PWMA_GCLK_FREQUENCY, EXAMPLE_PWMA_GCLK_ID, EXAMPLE_PWMA_GCLK_SOURCE, EXAMPLE_PWMA_OUTPUT_FREQUENCY, FAIL, genclk_enable_config(), gpio_enable_module_pin(), gpio_tgl_gpio_pin(), pwma, pwma_config_enable(), pwma_set_channels_value(), and sysclk_get_pba_hz().

Referenced by main().

volatile avr32_acifb_t* acifb = &AVR32_ACIFB

Global variable to Store the ACIFB module address.

Referenced by ac_init(), and ISR().

volatile avr32_pwma_t* pwma = &AVR32_PWMA

Global variable to Store the PWMA module address.

Referenced by ISR(), main(), and pwma_init().

volatile uint16_t read_top_value = 0

Variable to read the TOP value.

Referenced by ISR(), and main().