im trying to use ASF to schedule repeated tasks.
using TC4 and TC5:
in atmel start both using generic clock generator 0 (48MHz). both are HAL:DRIVER:Timer
driver init.c is generated automatically by atmel start:
- timer_1_init = TC4
- timer_0_init = TC5
when i comment Timer_1_init() ..
timer0 task runs ok.. however, when timer_1_init is called.. the task in tc4 is not called.
i read about tc4 and tc5 have same gclk id so i did this (enable both buses and then enable gclk channel) .. but same issue..
if i comment init of tc4:
- tc5 code works fine
if i comment init of tc5:
- tc4 code works fine
if i dont comment inits:
- tc5 task works (even if i init tc4 before init of tc5)
========= edit section =========
int32_t timer_init(struct timer_descriptor *const descr, void *const hw, struct _timer_hpl_interface *const func)
{
ASSERT(descr && hw);
_timer_init(&descr->device, hw);
descr->time = 0;
descr->device.timer_cb.period_expired = timer_process_counted;
return ERR_NONE;
}
note device->hw = hw in next func
int32_t _timer_init(struct _timer_device *const device, void *const hw)
{
int8_t i = get_tc_index(hw);
device->hw = hw;
ASSERT(ARRAY_SIZE(_tcs));
hri_tc_wait_for_sync(hw);
if (hri_tc_get_CTRLA_reg(hw, TC_CTRLA_ENABLE)) {
hri_tc_write_CTRLA_reg(hw, 0);
hri_tc_wait_for_sync(hw);
}
hri_tc_write_CTRLA_reg(hw, TC_CTRLA_SWRST);
hri_tc_wait_for_sync(hw);
hri_tc_write_CTRLA_reg(hw, _tcs[i].ctrl_a);
hri_tc_write_DBGCTRL_reg(hw, _tcs[i].dbg_ctrl);
hri_tc_write_EVCTRL_reg(hw, _tcs[i].event_ctrl);
if ((_tcs[i].ctrl_a & TC_CTRLA_MODE_Msk) == TC_CTRLA_MODE_COUNT32) {
hri_tccount32_write_CC_reg(hw, 0, _tcs[i].cc0);
hri_tccount32_write_CC_reg(hw, 1, _tcs[i].cc1);
} else if ((_tcs[i].ctrl_a & TC_CTRLA_MODE_Msk) == TC_CTRLA_MODE_COUNT16) {
hri_tccount16_write_CC_reg(hw, 0, (hri_tccount16_cc_reg_t)_tcs[i].cc0);
hri_tccount16_write_CC_reg(hw, 1, (hri_tccount16_cc_reg_t)_tcs[i].cc1);
} else if ((_tcs[i].ctrl_a & TC_CTRLA_MODE_Msk) == TC_CTRLA_MODE_COUNT8) {
hri_tccount8_write_CC_reg(hw, 0, (hri_tccount8_cc_reg_t)_tcs[i].cc0);
hri_tccount8_write_CC_reg(hw, 1, (hri_tccount8_cc_reg_t)_tcs[i].cc1);
hri_tccount8_write_PER_reg(hw, _tcs[i].per);
}
hri_tc_set_INTEN_OVF_bit(hw);
_tc_init_irq_param(hw, (void *)device);
NVIC_DisableIRQ((IRQn_Type)((uint8_t)TC_IRQ_BASE_INDEX + tc_get_hardware_index(hw)));
NVIC_ClearPendingIRQ((IRQn_Type)((uint8_t)TC_IRQ_BASE_INDEX + tc_get_hardware_index(hw)));
NVIC_EnableIRQ((IRQn_Type)((uint8_t)TC_IRQ_BASE_INDEX + tc_get_hardware_index(hw)));
return ERR_NONE;
}
==============
what causes this problem?