Timers
10-2
MC68328 USER’S MANUAL 12/9/97
MOTOROLA
TIMERS
10
PRELIMINARY
10.2 GENERAL-PURPOSE TIMER OPERATION
The clock input to the prescaler can be selected from the system clock (divided by 1 or 16),
the corresponding timer input (TIN1 or TIN2) pin, or the 32kHz (or 38kHz) reference clock.
The clock input source is selectable by configuring the CLKSOURCE field in the timer unit
1 and 2 control (TCTLx) registers. The prescaler can be programmed to divide the clock
input by a value between 1 and 256.
Each timer can be configured to count until it reaches a reference, in which case, the COMP
bit is set in the timer unit 1 and 2 status (TSTATx) registers. If the IRQEN bit is set in the
TCTLx, a maskable interrupt is generated to the processor. Notice that timer 1 event is a
level 6 interrupt and a timer 2 event is a level 4 interrupt. When the timer reaches the
reference value, the timer either resets itself immediately and starts counting from 0 or it
continues to count from its current value. You can configure this by setting or clearing the
FRR bit in the TCTLx.
Each timer can output a signal on the TOUT1 or TOUT2 pin when it reaches the reference
value as selected by the OM bit of the TCTLx. This signal can be either an active-low pulse
for one system clock or a toggle output. The output can also be used as a loopback input to
the second timer, which results in a 32-bit timer. Each timer has a 16-bit timer capture
register that latches the value of the counter when a defined transition of TIN1 or TIN2 is
sensed by the corresponding input capture edge detector. You can select the type of
transition that is triggering the capture by configuring the CE field in the TCTLx. When a
reference event occurs, the CAPT bit is set in the TSTATx and a maskable interrupt is
generated to the processor. Neither timer is active at reset and must be programmed
according to your application.
Figure 10-2. Software Watchdog Timer Block Diagram
RESET
COMPARATOR
COMPARE REGISTER
CLOCK
PRESCALER
16-BIT COUNTER
32KHZ CLOCK
MPU BUS
WATCHDOG TIMER
4KHZ
INTERRUPT