Add these macros to the top of your main application C-file:
#define TC TC0
#define TC_PERIPHERAL 0
#define TC_CHANNEL_CAPTURE 2
#define ID_TC_CAPTURE ID_TC2
#define PIN_TC_CAPTURE PIN_TC0_TIOA2
#define PIN_TC_CAPTURE_MUX PIN_TC0_TIOA2_MUX
#define TC_Handler TC2_Handler
#define TC_IRQn TC2_IRQn
Add this macro and functions to your main application C-file:
#define TC_CAPTURE_TIMER_SELECTION TC_CMR_TCCLKS_TIMER_CLOCK3
static
void tc_capture_initialize(
void)
{
sysclk_enable_peripheral_clock(ID_TC_CAPTURE);
#if SAMG55
pmc_disable_pck(PMC_PCK_3);
pmc_switch_pck_to_mck(PMC_PCK_3, PMC_PCK_PRES_CLK_1);
pmc_enable_pck(PMC_PCK_3);
#endif
tc_init(TC, TC_CHANNEL_CAPTURE,
TC_CAPTURE_TIMER_SELECTION
| TC_CMR_LDRA_RISING
| TC_CMR_LDRB_FALLING
| TC_CMR_ABETRG
| TC_CMR_ETRGEDG_FALLING
);
}
void TC_Handler(
void)
{
}