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
behind so I can enable it when I need a delay for a required time. So whenever I need a delay I call my
and it would do something like this.
`void delayms( uint16
t duration )
// Enable the timer
while (timeUp == false)
// 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;
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
if I needed a delay inside the body of the task. :/
Please let me know if you have any idea about this.