The HCS12 standard timer module is illustrated below.
Figure 8.1 HCS12 standard timer (TIM) block diagram.
The components are listed below:
TCNT
). Refer to 8.4 Timer Counter Register.I0C0
~ I0C7
).The timer counter TCNT
is a 16-bit register that counts form $0000
to $FFFF
. In particular, there are three registers related to the operation of this register.
TSCR1
): A register that controls the operation of the timer
counter.TSCR2
): Another register that controls the operation of the timer counter.TFLG2
): A register that controls the interrupt flag.To program the timer system, we must first enable the time counter. This can be done by setting the bit 7 of the TSCR1
. The TEN
bit allows the timer to be used.
Figure 8.2 Timer System Control register 1 (TSCR1
).
Upon enabling the time counter, it also needs a clock signal to operate.