English
Language : 

PIC32MX440F256H-80I Datasheet, PDF (350/646 Pages) Microchip Technology – 64/100-Pin General Purpose and USB 32-Bit Flash Microcontrollers
PIC32MX3XX/4XX
14.3 Modes of Operation
The 16-bit (default) and 32-bit mode timer peripherals
can operate as synchronous timer/counters using inter-
nal or external clock sources, or as synchronous gated
timers using an internal clock source and external
clock/gate pins. Each mode is easily configured and
described in the following sections.
14.3.1 CONSIDERATIONS FOR ALL TIMER
MODES
• A timer module is disabled and powered off when
the ON bit (TxCON<15>) = 0, thus providing
maximum power savings. All other TxCON bits
remain unchanged.
• Updates to the TxCON register should only be
performed when the timer module is disabled, ON
bit (TxCON<15>) = 0.
• A timer continues operating when the CPU goes
into Idle mode if the “Stop In Idle mode” control bit
is disabled, SIDL (TxCON<13>) bit = 0. If
enabled, SIDL = 1, the timer module stops
operation while the CPU is in Idle mode.
• Setting or clearing the ON bit (TxCON<15>) and
any other bits in the TxCON register during a
single instruction may cause undefined behavior.
The user is advised to program the TxCON
register with the desired settings with one instruc-
tion, and then set the ON bit in a subsequent
instruction.
14.3.2 16-BIT INTERNAL CLOCK
COUNTER/TIMER MODE
In this mode, the timer clock source is the internal
PBCLK (Peripheral Bus Clock), TCS (TxCON<1>) = 0.
The 16-bit TMRx Count register increments on every
internal PBCLK cycle when the timer clock prescale
<TCKPS> is 1:1.
The timer generates a timer match event after the
TMRx Count register matches the PRx Period register
value, then resets to 0x0000 on the next PBCLK clock
cycle. The timer continues to increment and repeat the
period match until the timer is disabled. For further
details regarding timer events and interrupts, see
Section 14.4 Timer Interrupts.
For clock prescale = N (other than 1:1), the timer oper-
ates at a clock rate = (PBCLK/N); therefore, the TMRx
Count register increments on every Nth PBCLK clock
cycle. For further details regarding timer prescaler,
refer to Section 14.3.9 Timer Clock Prescaler.
The following steps should be performed to properly
configure the 16-bit Timer peripherals for Timer mode
operation:
1. Clear ON control bit, (TxCON<15>) = 0, to
disable timer.
2. Configure TCKPS control bits, (TxCON<6:4), to
select desired timer clock prescale.
3. Set TCS control bit, (TxCON<1>) = 0, to select
the internal PBCLK clock source.
4. Clear TMRx register.
5. Load PRx register with desired 16-bit match
value.
6. If timer interrupts are to be used, refer to
Section 14.4 Timer Interrupts for interrupt
configuration steps.
7. Set ON control bit = 1 to enable Timer.
EXAMPLE 14-1:
T2CON = 0x0;
16-BIT INTERNAL CLOCK
COUNTER/TIMER
INITIALIZATION
//Stop and Init Timer
TMR2 = 0x0;
//Clear timer register
PR2 = 0xFFFF;
//Load period register
T2CONSET = 0x8000; // Start Timer
DS61143E-page 348
Preliminary
© 2008 Microchip Technology Inc.