??? 08/06/08 04:24 Read: times |
#157270 - Non Blocking timer |
Hi all I would like to know how you guys deal with long delays in code (> 1 sec)
I have a system that is purely interrupt driven and for non critical delays in the past I have set a delay_variable to a value and had a mSec timer, count it down, then set a flag when it reached 0, in the meantime I would have an "if" statement in a function that is frequently called to see if the flag is set or not. Worked fine not super accurate but good enough. I want to do this some_function(){ LED_ON wait(5secs) LED_OFF wait (60secs) LED2_ON wait (24secs) LED2_OFF } You get the idea anyway. Now I don't want to sit in a loop in the Wait function. but I don't want to set flags either as it is going to get really messing keeping track of where I am up to in my some_function. Ideally I would pass the wait() function two arguments, a wait time, and a return address, when the wait time completes via a timer interrupt or whatever, then it returns and continues where it left off. Any thoughts appreciated Regards Marshall Brown |