timer0_isr_interval

timer0 isr interval

Author Joep Suijs, Copyright © 2008 Joep Suijs
Adapted-by Rob Hamerling
Compiler 2.4q3

Description

Fixed interval isr with support for non-blocking delays.
.
The setup of this library is straight-forward. First you define the interval
of the interrupt you want. With a higher value, more interrupts are generated.
This gives a higher resolution of your delay, but also puts a high background
load on your PIC. Be carefull if you go beyond 1000 (1kHz). The lowest possible
rate depends on the clock frequency you use and is 77 with an 16f877 on 20 MHz.
.
   const TIMER0_ISR_RATE = 1000  -- 1 kHz isr rate
.
Next, you need to specify the number of slots. A slot is used to store the
end-time of a delay-period so you need one slot for each concurrent delay.
.
   const DELAY_SLOTS = 2         -- support 2 delays at the same time
.
Now, include the library and call its init function:
.
   include timer0_isr_interval
   timer0_isr_init()             -- init timer0 isr
.
Now we are ready to use the delay functions. To demonstrate its use, we take
two LEDs and let them blink at their own interval:
.
   forever loop
      if (check_delay(0)) then
         set_delay(0, 409)        -- 409 ticks on delay-slot 0
         led = !led
      end if
      if (check_delay(1)) then
         set_delay(1, 619)        -- 619 ticks on delay-slot 1
         led2 = !led2
      end if
   end loop


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

Here are the list of samples which use this library:

16f648a16f648a_timer0_interval.jal
16f69016f690_timer0_isr_interval.jal
16f72316f723_timer0_interval.jal
16f7316f73_timer0_interval.jal
16f87716f877_timer0_interval.jal
16f877a16f877a_timer0_interval.jal
16f8816f88_timer0_interval.jal
18f14k5018f14k50_timer0_interval.jal
18f245018f2450_timer0_interval.jal
18f252018f2520_timer0_interval.jal
18f255018f2550_timer0_interval.jal
18f262018f2620_timer0_interval.jal
18f45218f452_timer0_interval.jal
18f455018f4550_timer0_interval.jal
18f462018f4620_timer0_interval.jal
18f67j5018f67j50_timer0_interval.jal