I'm trying to do a quite simple thing: Configure a timer (ID_TC1) and get an interrupt when RC is reached.
My code is this one:
pmc_enable_periph_clk(ID_TC1); tc_find_mck_divisor(desired_freq, ul_sysclk, &ul_div, &ul_tc_clks, ul_sysclk); tc_init(TC0, 1, ul_tc_clks | TC_CMR_WAVSEL_UP_RC | TC_CMR_WAVE); tc_write_rc(TC0, 1, (ul_sysclk / ul_div) / desired_freq); NVIC_SetPriority(ID_TC1, IRQ_PRIOR_ENCODER); NVIC_EnableIRQ((IRQn_Type)ID_TC1); tc_enable_interrupt(TC0, 1, TC_IER_CPCS); tc_start(TC0, 1);
tc_find_mck_divisor find correct values : ul_tc_clks = 0, ul_div = 2.
TCCLKS = 0 means timer is clocked with PCK6, which is at 150MHz.
The problem is that it seems the timer never starts.
If I change the tc_init to:
tc_init(TC0, 1, 1 | TC_CMR_WAVSEL_UP_RC | TC_CMR_WAVE);
Here I use MCK/8 as timer clock, then timer starts and my TC1_Handler is correctly called.
Any idea what I'm doing wrong with this so simple timer configuration?