Timer/Counter example 3.
Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
#include <stdint.h>
#include <stdbool.h>
#include "sysclk.h"
#include "board.h"
#include "print_funcs.h"
#include "tc.h"
#include "gpio.h"
#include "intc.h"
#include "conf_example.h"
Functions | |
int | main (void) |
Main function: More... | |
static void | tc_init (volatile avr32_tc_t *tc) |
TC Initialization. More... | |
static void | tc_irq (void) |
TC interrupt. More... | |
Variables | |
static volatile uint32_t | tc_tick = 0 |
static volatile bool | update_timer = true |
int main | ( | void | ) |
Main function:
References cpu_irq_disable, cpu_irq_enable, EXAMPLE_TC, init_dbg_rs232(), INTC_init_interrupts(), INTC_register_interrupt(), print_dbg(), print_dbg_ulong(), sysclk_enable_peripheral_clock(), sysclk_get_pba_hz(), sysclk_init(), tc_init(), tc_irq(), tc_tick, timer, and update_timer.
|
static |
TC Initialization.
Initializes and start the TC module with the following:
tc | Base address of the TC module |
References tc_waveform_opt_t::channel, tc_interrupt_t::etrgs, sysclk_get_pba_hz(), TC_CLOCK_SOURCE_TC3, tc_configure_interrupts(), TC_EVT_EFFECT_NOOP, tc_init_waveform(), TC_SEL_NO_EDGE, tc_start(), TC_WAVEFORM_SEL_UP_MODE_RC_TRIGGER, and tc_write_rc().
Referenced by main().
|
static |
TC interrupt.
The ISR handles RC compare interrupt and sets the update_timer flag to update the timer value.
References EXAMPLE_TC, tc_read_sr(), tc_tick, and update_timer.
Referenced by init_timer_isr(), and main().