Programmable Timers
Am186™CC/CH/CU Microcontrollers User’s Manual
10-3
10.5
OPERATION
10.5.1
Usage
Note: If Timer 0 or Timer 1 is being used without the associated TMRIN pin, the pin must
be held high or programmed as a PIO, otherwise the timer will not increment. Before using
the programmable timers, ensure multiplexed pins are configured to reflect the use of the
timers and not other functionality (see Table 10-1).
1. Clear the current count by writing zero to the TxCNT register.
2. Specify the timer maximum count by writing to the Timer Maxcount Compare (TxCMPy)
registers for the timer being used.
3. Specify the actions taken when the timer count reaches maximum by setting bits in the
corresponding Timer Mode and Control (TxCON) register.
4. Enable the timer by setting both the EN and INH bits in the corresponding Timer Mode
and Control (TxCON) register.
The timer count registers can be read or written at any time, regardless of whether the
corresponding timer is running. The timers count from their initial value to the programmed
compare value and then reset on the same clock. The value in the timer count register
never equals the compare value.
If the external pins are used (Timer 0 and Timer 1), the PIO Mode and PIO Direction bits
for these pins must be configured for alternate operation. These pins are configured as
PIOs at external and internal reset. For more information, see Chapter 9, “Programmable
I/O Signals.”
10.5.2
Timer 2
When enabled, Timer 2 increments the T2CNT register value at every fourth processor
clock. After the timer increments, the microcontroller compares the T2CNT value with the
value of the T2CMPA register. When the two values are equal, the microcontroller takes
the following actions:
■
Resets T2CNT to zero and sets the MC (Max Count reached) bit in the T2CON register.
■
If the INT bit is set in T2CON, generates an interrupt request. Software must clear the
MC bit.
■
Sends a pulse to Timer 0 and Timer 1 which can be used to increment those timers.
■
Sends a DMA request to the general-purpose DMA—the DMA may act on or ignore this
request depending on how it is programmed.
■
If the CONT (continuous mode) bit is zero, clears the EN (enable) bit and the timer stops
counting. If CONT is one, the timer remains enabled and continues counting.
Since the comparison is done after the count is incremented, if T2CNT and T2CMPA are
initially set to the same value, the comparison of T2CNT to T2CMPA will not be equal until
4 • 0FFFFh processor clocks after the counter is enabled.
10.5.3
Timer 0 and Timer 1
Timers 0 and 1 provide identical functionality. Unlike Timer 2, Timers 0 and 1 each have
an input and output pin associated with the timer. They can also use Timer 2 as a prescaler
providing a 32-bit time-out count.
Содержание Am186 CC
Страница 1: ...Am186 CC CH CU Microcontrollers User s Manual Order 21914B...
Страница 4: ...iv Am186 CC CH CU Microcontrollers User s Manual...
Страница 18: ...Table of Contents xviii Am186 CC CH CU Microcontrollers User s Manual...
Страница 24: ...Introduction xxiv Am186 CC CH CU Microcontrollers User s Manual...
Страница 39: ...Architectural Overview Am186 CC CH CU Microcontrollers User s Manual 1 15 Figure 1 6 32 Channel Linecard CH CC...
Страница 40: ...Architectural Overview 1 16 Am186 CC CH CU Microcontrollers User s Manual...
Страница 86: ...System Overview 3 36 Am186 CC CH CU Microcontrollers User s Manual...
Страница 92: ...Emulator Support 4 6 Am186 CC CH CU Microcontrollers User s Manual...
Страница 112: ...DRAM Controller 6 8 Am186 CC CH CU Microcontrollers User s Manual...
Страница 134: ...Interrupts 7 22 Am186 CC CH CU Microcontrollers User s Manual...
Страница 186: ...Programmable I O Signals 9 8 Am186 CC CH CU Microcontrollers User s Manual...
Страница 200: ...Watchdog Timer 11 6 Am186 CC CH CU Microcontrollers User s Manual...
Страница 232: ...Asynchronous Serial Ports UARTs 13 24 Am186 CC CH CU Microcontrollers User s Manual...
Страница 242: ...Synchronous Serial Port SSI 14 10 Am186 CC CH CU Microcontrollers User s Manual...
Страница 264: ...High Level Data Link Control HDLC 15 22 Am186 CC CH CU Microcontrollers User s Manual...
Страница 332: ...Universal Serial Bus USB 18 34 Am186 CC CH CU Microcontrollers User s Manual...
Страница 348: ...Register Summary A 16 Am186 CC CH CU Microcontrollers User s Manual...
Страница 376: ...Index Index 18 Am186 CC CH CU Microcontrollers User s Manual...