| ??? 10/12/03 16:20 Read: times |
#56548 - RE: help me with timer on 89c2051 Responding to: ???'s previous message |
Setup the timer 0 as a "timer" and not a "counter". In timer mode the TIMER0 will be clocked from a path off the microcontroller oscillator. If you load it with a value it will then count up to 0xFFFF and then generate an interrupt. You can set the interrupt to happen say every 10 milliseconds (0.01 seconds). Configure yourself an interrupt service routine for the TIMER0 and inside the interrupt processing each time reload the timer 0 hardware with the divisor count to the next 10 millisecond interrupt. Then also have the interrupt logic manage a counter variable in an internal RAM location. This variable will count from 100 down to 0 and can be decremented each interrupt time. (The DJNZ instruction is very efficient for this function). When the variable has decremented to zero then reset it back to 100 and take whatever further action you wanted to happen on a 1 second basis.
Hope this helps Michael Karas |



