PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Feb 21, 2008 11:29 pm |
|
|
Calculate the rate of the timer interrupt.
The oscillator frequency is nominally 4.0 MHz.
Divide that by 4 to get the instruction clock: 1.0 MHz
You are using RTCC_DIV_16, so divide it by 16 to get: 62.5 KHz
This is the clock for Timer 0.
The timer rolls over and interrupts after 256 counts, so
divide 62.5 KHz by 256 to get the interrupt rate: 244.14062 Hz
This means the timer interrupt occurs approximately 244 times
per second.
Currently, you check if it counts to 250 before you increment
the 'seconds' counter. Change it to the correct count. |
|