How to handle missed ticks

I have a question regarding the tick interrupt and xTaskIncrementTick:

  • How to handle cases, where the time between two tick interrupts is longer then two tick periods? Is it okay to call xTaskIncrementTick multiple times in the same IRQ to sync up?

  • I see that the official ports ignore this case, so I guess, it is not allowed to have a IRQ load that high or if a task disables the irqs it has to compensate for that. Correct?

1 Like

How do you know that this happens? Do you match time against an RTC? Your timer tick IS the OSs time base…

See xTaskCatchUpTicks() – API docs here.

Best is to avoid that happening, then you don’t have to handle the case. How fast is your tick interrupt? What is causing it to be masked for that long (critical section, higher priority interrupts, whatever)? Is it critical to your application if time slips by one tick?

I saw it happening because the Tick Timer implementation in the TC3 is not self updating. So the timer run beyond the compare value and needed a complete wrap around to trigger again.
It happend by accident, the frequency is 10kHz and I had uart code blocking the irqs by accident. But since I’m working on the Infineon TC3 port, I wanted to make sure, how to handle those cases. I added an assert with a comment, that I shouldn’t happen by design.
Thanks for the replies :slight_smile: