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 05:02
Read: times


 
#70096 - RE: Can we expand the timers in 89c52 uC
Responding to: ???'s previous message
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. The number of timers that can be supported is dependent on several factors which include:

A) How much RAM is available to store the software timer values.

B) How much count range the software timers will require, 8-bits, 16-bits, 32-bits etc.

C) How much resolution the timers will require per increment of count. (This relates directly to the rate at which the timer interrupt is programmed.

To implement this scheme have the timers in RAM such as:


unsigned char TimerA;
unsigned char TimerB;
unsigned char TimerC;


In the wakeup initialization code get the timers initialized as:


TimerA = 0;
TimerB = 0;
TimerC = 0;


In the timer interrupt processing routine you will have code as such:

if(TimerA != 0)
{
   TimerA--;
}
if(TimerB != 0)
{
   TimerB--;
}
if(TimerC != 0)
{
   TimerC=-;
}


Then in the main part of the application whenever you want to have timing delay or measurement you set the software timer value to some count. The software timer can then be polled from time to time to see if it has timed out (i.e. gone to a zero value). Note that if you implement timers at sizes greater than 8-bits wide it is necessary to disable interrupts for the short period of time that the main application program attempts to set a timer value or read a timer value.

It is for this latter reason that I normally only make byte wide timers. I'll then arrange to have some timers that operate at resolutions equal to the interrupt rate such as 10 milliseconds. I then make others that are processed only every 10 and every 100 timer interrupts so I can have resolutions of say 100 milliseconds and 1000 milliseconds. A byte wide timer at 1000 milliseconds resolution can time events to 255 seconds (or just over 3 minutes).

Michael Karas




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