Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
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






List of 27 messages in thread
TopicAuthorDate
Non Blocking timer            01/01/70 00:00      
   Use a hardware timer            01/01/70 00:00      
      Thanks - But.....            01/01/70 00:00      
         State machines            01/01/70 00:00      
            THANKS - That's a great idea            01/01/70 00:00      
               if you have a lot to delay by various delays            01/01/70 00:00      
                  I Like that Idea as well            01/01/70 00:00      
                  A Linked List might be better here            01/01/70 00:00      
                     the correct use takes care of this            01/01/70 00:00      
                        Not necessarily            01/01/70 00:00      
   Cooperative or preemptive multitasking            01/01/70 00:00      
      Super-loop contra cooperative multitasking            01/01/70 00:00      
         Multasking can work on the 8051 ... sometimes            01/01/70 00:00      
            Not just stack            01/01/70 00:00      
               I agree            01/01/70 00:00      
                  Choose your battles carefully            01/01/70 00:00      
               I agree, too            01/01/70 00:00      
                  and            01/01/70 00:00      
                     Never underestimate the usefulnes of interrupts            01/01/70 00:00      
                        a flavor            01/01/70 00:00      
                           prioritizing in super-loop            01/01/70 00:00      
                              the fact is ..            01/01/70 00:00      
                  C works well            01/01/70 00:00      
                  Circular argument?            01/01/70 00:00      
                     Re: Circular Argument            01/01/70 00:00      
                        going round in circles            01/01/70 00:00      
            small multitasker            01/01/70 00:00      

Back to Subject List