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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/10/04 22:24
Read: times


 
#70144 - 48 Timers?!
Responding to: ???'s previous message
Michael Karas said:
The commercial PLC device uses a single timer interrupt from the timer hardware and then implements the "application timers" according to the scheme I will describe.

Wouldn't that scheme get a bit unwieldy for the 48 (or more!) timers mentioned in the OP?!

For such large numbers of timers, it might be better to have the ISR just generate a 'tick', and then the main loop implement the "application timers".
A linked list can be used to advantage here:

Initially, all 48 (or whatever) timers are idle, and linked into a "free" queue;
When a timer is started, it is moved into the "active" queue;
Each time round the main loop, the "application timer" handler walks the "active" queue, updating all the timers in it (ie, all the active timers)
When a timer expires, its expiry flag is set, and it is moved back to the "free" queue.

Note that this does not require the use of dynamic memory allocation: the required number of timers can be defined at compile time - at runtime, it's just a matter of linking them into the "free" or "active" list.
(In fact, you might not even need the "free" queue at all).

Another advantage is that changing the number of timers is easy - you don't have to update hard-coded entries in the ISR!

List of 7 messages in thread
TopicAuthorDate
Can we expand the timers in 89c52 uC            01/01/70 00:00      
   RE: Can we expand the timers in 89c52 uC            01/01/70 00:00      
      RE: Can we expand the timers in 89c52 uC            01/01/70 00:00      
      48 Timers?!            01/01/70 00:00      
         RE: 48 Timers?!            01/01/70 00:00      
   RE: Can we expand the timers in 89c52 uC            01/01/70 00:00      
   Same old wine in a new bottle            01/01/70 00:00      

Back to Subject List