UM10346_1
© NXP B.V. 2009. All rights reserved.
User manual
Rev. 01 — 2 November 2009
44 of 132
NXP Semiconductors
UM10346
LPC980/982 User manual
In this mode, the Timer register is configured as a 13-bit register. As the count rolls over
from all 1s to all 0s, it sets the Timer interrupt flag TFn. The count input is enabled to the
Timer when TRn = 1 and either TnGATE = 0 or INTn = 1. (Setting TnGATE = 1 allows the
Timer to be controlled by external input INTn, to facilitate pulse width measurements).
TRn is a control bit in the Special Function Register TCON (
). The TnGATE bit is
in the TMOD register.
The 13-bit register consists of all 8 bits of THn and the lower 5 bits of TLn. The upper 3
bits of TLn are indeterminate and should be ignored. Setting the run flag (TRn) does not
clear the registers.
Mode 0 operation is the same for Timer 0 and Timer 1. See
. There are two
different GATE bits, one for Timer 1 (TMOD.7) and one for Timer 0 (TMOD.3).
7.2 Mode 1
Mode 1 is the same as Mode 0, except that all 16 bits of the timer register (THn and TLn)
are used. See
7.3 Mode 2
Mode 2 configures the Timer register as an 8-bit Counter (TLn) with automatic reload, as
shown in
. Overflow from TLn not only sets TFn, but also reloads TLn with the
contents of THn, which must be preset by software. The reload leaves THn unchanged.
Mode 2 operation is the same for Timer 0 and Timer 1.
7.4 Mode 3
When Timer 1 is in Mode 3 it is stopped. The effect is the same as setting TR1 = 0.
Timer 0 in Mode 3 establishes TL0 and TH0 as two separate 8-bit counters. The logic for
Mode 3 on Timer 0 is shown in
. TL0 uses the Timer 0 control bits: T0C/T,
T0GATE, TR0, INT0, and TF0. TH0 is locked into a timer function (counting machine
cycles) and takes over the use of TR1 and TF1 from Timer 1. Thus, TH0 now controls the
‘Timer 1’ interrupt.
Mode 3 is provided for applications that require an extra 8-bit timer. With Timer 0 in Mode
3, an P89LPC980/982 device can look like it has three Timer/Counters.
Note: When Timer 0 is in Mode 3, Timer 1 can be turned on and off by switching it into and
out of its own Mode 3. It can still be used by the serial port as a baud rate generator, or in
any application not requiring an interrupt.
7.5 Mode 6
In this mode, the corresponding timer can be changed to a PWM with a full period of 256
timer clocks (see
). Its structure is similar to mode 2, except that:
•
TFn (n = 0 and 1 for Timers 0 and 1 respectively) is set and cleared in hardware;
•
The low period of the TFn is in THn, and should be between 1 and 254, and;
•
The high period of the TFn is always 256
−
THn.
•
Loading THn with 00h will force the Tx pin high, loading THn with FFh will force the Tx
pin low.