Hey Richard,
I have done some testing and this is the summery.
I have created my own delay using TC3 and initialize my delay_ms at the start of my program before the task scheduler start and only leave the
enable_tc()
behind so I can enable it when I need a delay for a required time. So whenever I need a delay I call my
delay_ms()
and it would do something like this.
`void delay
ms( uint16t duration )
{
// Enable the timer
tc_enable(&tc_);
while (timeUp == false)
{
sleepmgr_enter_sleep();
}
// The moment the callback gets triggered I change the value of timeUp inside it so I would jump out of the blocking while above.
timeUp = false;
tc_disable(&tc_);
}
`
I can do:
When I enable my TC from within the body of one of the tasks, the relevant callback gets triggered.
I cannot do:
When I enable my TC from within a body of a i2c callback method, the relevant callback never gets called.
I have gone up and down and checked all the hardware values and put a watch on any var you can imagine but I cannot draw any conclusion that, why I cannot trigger a TC interrupt from within a body of a non task method ( in this example, i2c callback ). And to be honest, this is the only place I would need a delay which works using a hardware counter. I could have easily used the
vTaskDelay()
if I needed a delay inside the body of the task. :/
Please let me know if you have any idea about this.