Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

TIM0-4, $D0-4

Register    Period      Counts to   Width in bits
TIM0        5ms         199         8
TIM1        1 second    59          6
TIM2        1 minute    255         8
TIM3        256 minutes 255         8
TIM4        64K minutes 31          5

The clock is reset to zero by settings RESTIM in the COM register. The clock will be held in reset, ie. it won't count until RESTIM is cleared again. In order to guarantee a valid result from any of these registers, software needs to read until two equal values are returned. This should always occur within three read cycles.

There are three interrupts that the real time clock can generate and these are TICK (100 times a second), SEC (once a second) and MIN (once a minute). Three registers are associated with these interrupts:

TSTA ($B5), Timer interrupt status

BIT         NAME        Function
7 - 3       -           -
2           MIN         Set if minute interrupt has occurred
1           SEC         Set if second interrupt has occurred
0           TICK        Set if tick interrupt has occurred

TMK ($B5), Timer interrupt mask

BIT         NAME        Function
7 - 3       -           -
2           MIN         Set to enable minute interrupt
1           SEC         Set to enable second interrupt
0           TICK        Set to enable tick interrupt

TACK ($B4), Timer interrupt acknowledge

BIT         NAME        Function
7 - 3       -           -
2           MIN         Set to acknowledge minute interrupt
1           SEC         Set to acknowledge second interrupt
0           TICK        Set to acknowledge tick interrupt