AMD Am188TMER Microscope & Magnifier User Manual


 
Timer Control Unit
9-1
CHAPTER
9
TIMER CONTROL UNIT
9.1 OVERVIEW
There are three 16-bit programmable timers in the Am186ER and Am188ER
microcontrollers. Timers 0 and 1 are highly versatile and are each connected to two external
pins (each one has an input and an output). These two timers can be used to count or time
external events, or they can be used to generate nonrepetitive or variable-duty-cycle
waveforms. Timer 1 can also be configured as a watchdog timer.
The watchdog timer provides a mechanism for detecting software crashes or hangs. The
TMROUT1 output is internally connected to the watchdog timer interrupt. Software
developers must first program the TIMER1 Mode/Control, Count, and Max Count registers,
and then program the Watchdog Timer Interrupt Control register (see Figure 8-8 on page
8-19). The TIMER1 Count register must be reloaded at intervals less than the TIMER1 max
count to assure the watchdog interrupt is not taken. If the code crashes or hangs, the
TIMER1 countdown can cause a watchdog interrupt.
Timer 2 is not connected to any external pins. It can be used for real-time coding and time-
delay applications. It can also be used as a prescale to timer 0 and timer 1 or as a DMA
request source.
9.2 PROGRAMMABLE REGISTERS
The timers are controlled by eleven 16-bit registers (see Table 9-1) that are located in the
peripheral control block.
Table 9-1 Timer Control Unit Register Summary
The timer-count registers contain the current value of a timer. The timer-count registers
can be read or written at any time, regardless of whether the corresponding timer is running.
The microcontroller increments the value of a timer-count register each time a timer event
occurs.
Offset from
PCB
Register
Mnemonic Register Name
56h T0CON Timer 0 Mode/Control
5Eh T1CON Timer 1 Mode/Control
66h T2CON Timer 2 Mode/Control
50h T0CNT Timer 0 Count
58h T1CNT Timer 1 Count
60h T2CNT Timer 2 Count
52h T0CMPA Timer 0 Maxcount Compare A
54h T0CMPB Timer 0 Maxcount Compare B
5Ah T1CMPA Timer 1 Maxcount Compare A
5Ch T0CMPB Timer 1 Maxcount Compare B
62h T2CMPA Timer 2 Maxcount Compare A