Author | Joep Suijs, Copyright © 2008 Joep Suijs |
Adapted-by | Rob Hamerling |
Compiler | >=2.4j |
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 it's init function: . >>> include timer0_isr_interval >>> timer0_isr_init() -- init timer0 isr . Now we are ready to use the delay functions. To demonstrate it's 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
No dependency found
var word internal_isr_counter
No documentation found
var word isr_countdown[DELAY_SLOTS]
No documentation found
var byte timer0_load
No documentation found
timer0_isr_init()
No documentation found
set_delay(byte in slot, word in ticks)
No documentation found
ISR()
No documentation found
isr_counter'get() return word
No documentation found
check_delay(byte in slot) return bit
No documentation found
16f648a | 16f648a_timer0_interval.jal |
16f690 | 16f690_timer0_isr_interval.jal |
16f723 | 16f723_timer0_interval.jal |
16f73 | 16f73_timer0_interval.jal |
16f877 | 16f877_timer0_interval.jal |
16f877a | 16f877a_timer0_interval.jal |
16f88 | 16f88_timer0_interval.jal |
18f14k50 | 18f14k50_timer0_interval.jal |
18f2450 | 18f2450_timer0_interval.jal |
18f2520 | 18f2520_timer0_interval.jal |
18f2550 | 18f2550_timer0_interval.jal |
18f2620 | 18f2620_timer0_interval.jal |
18f452 | 18f452_timer0_interval.jal |
18f4550 | 18f4550_timer0_interval.jal |
18f4620 | 18f4620_timer0_interval.jal |
18f67j50 | 18f67j50_timer0_interval.jal |