Author: jsuijs
Date: Mon Dec 29 13:04:39 2008
New Revision: 668
Modified:
trunk/unvalidated/include/peripheral/timer/timer0_isr_interval.jal
trunk/unvalidated/sample/test/peripheral/timer/test_timer0_interval.jal
Log:
enhancement of timer/timer0_isr_interval.jal (see also the blog!)
Modified: trunk/unvalidated/include/peripheral/timer/timer0_isr_interval.jal
==============================================================================
--- trunk/unvalidated/include/peripheral/timer/timer0_isr_interval.jal
(original)
+++ trunk/unvalidated/include/peripheral/timer/timer0_isr_interval.jal Mon
Dec 29 13:04:39 2008
@@ -11,12 +11,21 @@
-- TODO:
--
-var word isr_counter
-var word prev_isr_counter
+var word internal_isr_counter
var word isr_countdown[DELAY_SLOTS]
var byte timer0_load
+function isr_counter return word is
+ var word temp
+
+ INTCON_T0IE = off
+ temp = internal_isr_counter
+ INTCON_T0IE = on
+
+ return temp
+end function
+
procedure set_delay(byte in slot, word in ticks) is
if (slot >= DELAY_SLOTS) then return end if
@@ -91,6 +100,11 @@
INTCON_GIE = on ; enable global interrupts
INTCON_PEIE = on
+ var byte i
+ for DELAY_SLOTS using i loop
+ isr_countdown[i] = 0
+ end loop
+
end procedure
@@ -101,7 +115,7 @@
tmr0 = timer0_load
-- counters
- isr_counter = isr_counter + 1
+ internal_isr_counter = internal_isr_counter + 1
var byte index
for DELAY_SLOTS using index loop
Modified:
trunk/unvalidated/sample/test/peripheral/timer/test_timer0_interval.jal
==============================================================================
--- trunk/unvalidated/sample/test/peripheral/timer/test_timer0_interval.jal
(original)
+++ trunk/unvalidated/sample/test/peripheral/timer/test_timer0_interval.jal
Mon Dec 29 13:04:39 2008
@@ -17,6 +17,7 @@
;@jallib use chipdef
;@jallib use led
+
led_direction = output
led2_direction = output
@@ -25,10 +26,11 @@
-- setup the timer0_isr_interval library
const timer0_isr_rate = 1000 -- 1 kHz isr rate
-const DELAY_SLOTS = 2
+const DELAY_SLOTS = 2 -- support 2 delays at the same time
include timer0_isr_interval
-timer0_isr_init()
+timer0_isr_init() -- init timer0 isr
+var word prev_isr_counter
forever loop
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"jallib" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/jallib?hl=en
-~----------~----~----~----~------~----~------~--~---