Idea.
Set up a timer interrupt to check the pin every second. After 300 seconds if the pin is still high then..
Idea.
Set up a timer interrupt to check the pin every second. After 300 seconds if the pin is still high then..
Dave
Always wear safety glasses while programming.
You can also do this without interrupts by just monitoring a timer overflow flag bit.
Here's one example;
http://www.picbasic.co.uk/forum/showthread.php?t=6957
Hi Bruce. At the link above, you posted a timer code. I do not get it why you are adding the timer value to the T1LO/T1HI values instead off just loading the timer with the timout value.
Sorry I seem like Goofy right now....
Ioannis
Hi Ioannis,
I think doing it that way accounts for any variance in latency etc. Since the code just polls TMR1 interrupt flag rather than actually cause an interrupt the timer may have counted "a while" before the code actually gets to reloading it. If you then simply reload it the time already passed since it overflowed will get lost. By adding the preload value to the actual value already accumulated in the timer you won't loose any time.
Does that make any sense?
/Henrik.
Ohh yeah! I see the light!
Thanks Henrik.
Ioannis
Last edited by Ioannis; - 19th May 2010 at 19:49.
Bookmarks