English
Language : 

PIC32MX440F256H-80I Datasheet, PDF (352/646 Pages) Microchip Technology – 64/100-Pin General Purpose and USB 32-Bit Flash Microcontrollers
PIC32MX3XX/4XX
EXAMPLE 14-3:
T4CON = 0x0;
16-BIT GATED CLOCK
COUNTER/TIMER
INITIALIZATION
//Stop and Init Timer
T4CON = 0x00E0;
TMR4 = 0;
//Enable gated mode,
//prescaler=1:64,
//internal clock
//Clear timer register
PR4 = 0xFFFF;
//Load period register
T4CONSET = 0x8000;//Start Timer
14.3.5 32-BIT INTERNAL CLOCK
COUNTER/TIMER MODE
In this mode, T32 (TxCON<3>) = 1 and the timer clock
source is the internal PBCLK (Peripheral Bus Clock),
TCS (TxCON<1>) = 0. The 32-bit TMRxy Count regis-
ter increments on every internal PBCLK cycle when the
timer clock prescale <TCKPS> is 1:1.
The timer generates a timer match event after the
TMRxy Count register matches the PRxy Period regis-
ter value, then resets to 0x00000000 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 TMRxy
Count register increments on every Nth PBCLK clock
cycle. For further details regarding the timer prescaler,
refer to Section 14.3.9 Timer Clock Prescaler.
14.3.6 CONSIDERATIONS
• 32-bit timer pairs can be created using Timer2
with Timer3, or Timer4 with Timer5.
• With Timer2 or Timer4 enabled, setting the T32 bit
(T2CON<3> or T4CON<3>) = 1 automatically
enables the corresponding Timer3 or Timer5
module. For this reason, it is not necessary to
manually enable Timer3 or Timer5.
• T2CON and T4CON control registers are used for
configuring the 32-bit timer operations; Writes to
T3CON and T5CON are ignored.
• T2CK and T4CK input pins are utilized for the 32-
bit gated timer or external synchronous counter
operations; T3CK and T5CK are ignored.
• 32-bit timer interrupts use Timer3 or Timer5 inter-
rupt enable bits and interrupt flag bits; Timer2 and
Timer4 interrupt enable and interrupt flag bits are
ignored.
• Load TMRxy pair by writing the 32-bit value to
TMRx.
• Load PRxy pair by writing the 32-bit value to PRx.
The following steps should be performed to properly
configure the 32-bit timer peripherals for Timer mode
operation.
1. Clear control bit, ON (TxCON<15>) = 0, to
disable timer.
2. Set control bit, T32 (TxCON<3>).
3. Select the desired timer prescaler using bits
TCKPS<2:0> (TxCON<6:4>).
4. Set control bit, TCS (TxCON<1>) = 0, to select
the internal clock source.
5. Clear Timer register, TMRxy.
6. Load Period register, PRxy, with desired 32-bit
match value.
7. If timer interrupts are used, refer to Section 14.4
Timer Interrupts for interrupt configuration
steps.
8. Set control bit, ON (TxCON<15>) = 1, to enable
timer.
EXAMPLE 14-4:
32-BIT INTERNAL CLOCK
COUNTER/TIMER
INITIALIZATION
T4CON = 0x0;
//Stop Timer4 and clear
T5CON = 0x0;
//Stop Timer5 and clear
T4CONSET = 0x0038; // Enable 32-bit mode,
// prescaler at 1:8,
// internal clock
TMR4 = 0x0;
// Clear TMR4 and TMR5
// Same as TMR4 = 0x0
PR4 = 0xFFFFFFFF; // Load PR4 and PR5
// with 32-bit value
// Same as PR4=0xFFFFFFFF
T4CONSET = 0x8000; // Start Timer
DS61143E-page 350
Preliminary
© 2008 Microchip Technology Inc.