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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/04/10 07:49
Read: times


 
#173819 - Interrupts aren't the biggest problem ...
Responding to: ???'s previous message
Erik Malund said:
alarm = T2L + ticks;
while (T2L != alarm) ;


non-functional code, what if an interrupt happens. If so, T2L can be == alarm many times before you detect it.


I don't think interrupts are the biggest problem - what if the while loop takes more than one cycle to execute? Actually, that's no "if", that's pretty much certain. The uC is going to "miss" the instant during which the condition is true a few times, or possibly forever.

"Fortunately", the 8051s timers have ways of telling the rest of the processor that a timer overflow has happened. Use those instead.

List of 9 messages in thread
TopicAuthorDate
fixed length delays in C            01/01/70 00:00      
   Can't do it without assembly.            01/01/70 00:00      
      HLL gives no guarantees            01/01/70 00:00      
      Using a timer in C            01/01/70 00:00      
         overheads            01/01/70 00:00      
            Use a dedicated timer            01/01/70 00:00      
               non-functional code            01/01/70 00:00      
                  Interrupts aren't the biggest problem ...            01/01/70 00:00      
   break apart            01/01/70 00:00      

Back to Subject List