The DELAYS_TMR0 unit

Libraries ››
Parent Previous Next

Set of functions and procedures to manage precise delay slots using the TMR0 interrupt.

Demo project: None.


 - Joep Suijs (jsuijs): Original idea of "non blocking delays" in JALLIB.

 - Vasi (funlw65): Initial port from JAL to PMP Pascal.

 - Philippe Paternotte (PPA).


This unit may handle one to many precise times, with an accuracy equal to the TMR0 interrupt rate.

The number of timer "slots" is defined at compile time to generate a code as light as it may be.

One timer "slot" may handle:

- An elapsed condition (this bit is set each time the timer has elapsed, the bit is cleared when it is read).

- A remaining ticks counter (read the remaining ticks until "terminated" or "elapsed" condition).

- A single shot mode (the timer runs once).

Note: Even if the TMR0 rate is low, having too many slots may not be a good idea because it may generate a lot of interrupt overhead that may have some incidence in the main program process. If so, it may be a better idea to count the elapsed condition of a common timer slot in separate counters in the main program and to execute actions depending on these counts.