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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/14/03 14:38
Read: times


 
#39069 - understanding timers
This is more a question to understand timers than a real problem. I am using an atmel 89LV52 mcu (xstal at 12mhz, so 1us machine cycle).
I use timer0 to toggle the state of a pin to use it as an oscillator. so timer0 is a 16 bits counter and set TH0, TL0 to generate an interrupt every 400us (does not really matter...) In a main loop I have

while (1)
{
oscillator();
another_task();
}

and the prototype for oscillator :

void oscillator (void)
{
if (global_count == 100)
{
TR0=0;
P1.1=~P1.1;
global_count=0; /*reset global value global_count increment in timer0_ISR */
TR0=1;
}
}

What I would like to know is when, from the while loop, I am in another_task, is the global value global_count still incremented every 1us, and how to synchronise the test in oscillator() if it takes too long to execute another_task (global_count > 100)apart from adding oscillator into timer0_ISR (should be as small as possible no?) or is it 'multitasking' the 2 task (increment value and performs another_task )

Also when timer1 is used as a baud rate generator, will i get the same problem ? I mean same program as before, timer0_ISR and another_task running and rs232 reception (or emission) is happening ?

thanks for answering


List of 8 messages in thread
TopicAuthorDate
understanding timers            01/01/70 00:00      
   RE: understanding timers            01/01/70 00:00      
      RE: understanding timers            01/01/70 00:00      
   RE: understanding timers            01/01/70 00:00      
   RE: understanding timers            01/01/70 00:00      
      RE: understanding timers, Michael            01/01/70 00:00      
         RE: understanding timers, Michael            01/01/70 00:00      
      RE: understanding timers            01/01/70 00:00      

Back to Subject List