English
Language : 

PIC32MX440F256H-80I Datasheet, PDF (379/646 Pages) Microchip Technology – 64/100-Pin General Purpose and USB 32-Bit Flash Microcontrollers
PIC32MX3XX/4XX
9. Set the OCM bits to ‘100’ and the OCTSEL
(OCxCON<3>) bit to the desired timer source.
The OCx pin state will now be driven low.
10. Set the ON (TxCON<15>) bit to ‘1’ which enables
the compare time base to count.
11. Upon the first match between TMRx and OCxR,
the OCx pin will be driven high.
12. When the incrementing timer matches the Sec-
ondary Compare register, OCxRS, the second
and trailing edge (high-to-low) of the pulse is
driven onto the OCx pin. No additional pulses are
driven onto the OCx pin and it remains at low. As
a result of the second compare match event, the
OCxIF interrupt flag bit is set, which will result in
an interrupt if it is enabled, by setting the OCxIE
bit. For further information on peripheral
interrupts, refer to Section 8.0 “Interrupts”.
13. To initiate another single pulse output, change the
Timer and Compare register settings, if needed,
and then issue a write to set the OCM bits to ‘100’.
Disabling and re-enabling of the timer and clear-
ing the TMRx register are not required, but may
be advantageous for defining a pulse from a
known event time boundary.
EXAMPLE 16-1: EXAMPLE CODE
// The following code example will set the Output Compare 1 module for interrupts on the
// single pulse event and select Timer 2 as the clock source for the compare time base.
T2CON = 0x0010;
// Configure Timer 2 for a prescaler of 2
OC1CON = 0x0000;
OC1CON = 0x0004;
OC1R = 0x3000;
OC1RS = 0x3003;
PR2 = 0x3003;
// Turn off OC1 while doing setup.
// Configure for single pulse mode
// Initialize primary Compare Register
// Initialize secondary Compare Register
// Set period (PR2 is now 32-bits wide)
IF0CLR = 0x00000080;
IE0SET = 0x00000080;
IPC1SET = 0x0030000;
IPC1SET = 0x00000003;
// configure int
// Clear the OC1 interrupt flag
// Enable OC1 interrupt
// Set OC1 interrupt subpriority to 3,
// the highest level
// Set subpriority to 3, maximum
T2CONSET = 0x8000;
OC1CONSET = 0x8000;
// Enable timer2
// Enable the OC1 module
// Example code for Output Compare 1 ISR:
void__ISR (_OUTPUT_COMPARE__1_VECTOR, ipl4) OC1_IntHandler(void)
{
// insert user code here
IFS0CLR = 0x00000080; // Clear the OC1 interrupt flag
}
© 2008 Microchip Technology Inc.
Preliminary
DS61143E-page 377