Revision: 1903
Author: bvwelch
Date: Fri Apr  9 12:25:56 2010
Log: sample app for timer0 polled interval library

http://code.google.com/p/jallib/source/detail?r=1903

Added:
 /trunk/sample/18f4585_tmr0_poll_interval.jal

=======================================
--- /dev/null
+++ /trunk/sample/18f4585_tmr0_poll_interval.jal        Fri Apr  9 12:25:56 2010
@@ -0,0 +1,59 @@
+-- Title: test timer0 interval w/ polling
+--
+-- Author: Joep Suijs, Copyright (c) 2008, all rights reserved.
+-- Adapted-by: William Welch
+-- Compiler: >=2.4m
+--
+-- This file is part of jallib (http://jallib.googlecode.com)
+-- Released under the BSD license (http://www.opensource.org/licenses/bsd-license.php)
+--
+-- Description: test the library timer0_poll_interval
+--
+
+include 18f4585
+pragma target clock 20_000_000
+pragma target OSC  HS
+pragma target XINST disabled
+pragma target WDT  disabled
+pragma target LVP  disabled
+pragma target MCLR external
+
+-- LED IO definition
+alias led             is pin_b1
+alias led_direction   is pin_b1_direction
+alias led2            is pin_c2
+alias led2_direction  is pin_c2_direction
+
+led_direction = output
+led2_direction = output
+
+-- set all IO as digital
+enable_digital_io()
+
+-- setup the timer0_poll_interval library
+const timer0_overflow_rate = 1000  -- 1 kHz overflow rate
+const DELAY_SLOTS = 2         -- support 2 delays at the same time
+include timer0_poll_interval
+timer0_poll_init()             -- init timer0
+
+var word prev_interval_counter
+
+forever loop
+
+   if (timer0_interval_counter != prev_interval_counter) then
+      prev_interval_counter = timer0_interval_counter
+      -- put here code that you want
+      -- to execute each tick.
+   end if ; 1 kHz 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
+
+; end of main

--
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.

Reply via email to