??? 07/25/05 18:03 Read: times |
#98082 - Thanks... and some basic timer concepts Responding to: ???'s previous message |
Thank you all for your replies. It is valued advice. I think I have gleaned some useful information as follows:
1. Software delays are tricky, potentially unreliable and tie up the processor anyway. I am going to try and find a way to use the timer instead for a specified delay period. 2. "Magic Numbers" are generally uncool in C programming (and probably any language). I have eliminated them from my code. 3. Relying on the actual current value of a given port for decision making may be risky. I am going to set up a variable instead. There seemed to be some conflicting opinions about ISR code for timers. Perhaps it would be better if I asked conceptually. Which of the following statments are true? A. When a timer overflows and the ISR code is called, the timer waits for the code in the ISR routine to finish before resuming its count. So a large ISR code could throw off the timer. B. When a timer overflows it sets the overflow flag and keeps going, thus the timer is always accurate, BUT you had better hope that your ISR code finishes and gets that overflow flag reset before the timer overflows again. C. I have missed the boat entirely and A & B are both false. D. It depends on what kind of timer you are talking about (i.e. 8 bit auto-reload, 16 bit etc.) Adam |