8.3 Standard Timer Module

The HCS12 standard timer module is illustrated below.

Figure 8.1 HCS12 standard timer (TIM) block diagram.

Figure 8.1 HCS12 standard timer (TIM) block diagram.

The components are listed below:

8.4 Timer Counter Register

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.

  1. Timer System Control Register 1 (TSCR1): A register that controls the operation of the timer counter.
  2. Timer System Control Register 2 (TSCR2): Another register that controls the operation of the timer counter.
  3. Timer Interrupt Flag 2 Register (TFLG2): A register that controls the interrupt flag.

Programming the Timer System

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 ().

Figure 8.2 Timer System Control register 1 (TSCR1).

Upon enabling the time counter, it also needs a clock signal to operate.