English
Language : 

PIC32MX440F256H-80I Datasheet, PDF (549/646 Pages) Microchip Technology – 64/100-Pin General Purpose and USB 32-Bit Flash Microcontrollers
PIC32MX3XX/4XX
24.6 Interrupts
EXAMPLE 24-1: COMPARATOR INITIALIZATION WITH INTERRUPTS ENABLED CODE EXAMPLE
CM1CON = 0xC0D0;
CM2CON = 0xA0C2;
// Configure both comparators to generate an interrupt on any
// output transition
// Initialize Comparator 1
// Comparator enabled, output enabled, interrupt on any output
// change, inputs: CVref, C1IN-
// Initialize Comparator 2
// Comparator enabled, output enabled, interrupt on any output
// change, inputs: C2IN+, C1IN+
IPC7SET = 0x00000700;
IFS1CLR = 0x00000008;
IEC1SET = 0x00000008;
// Enable interrupts for Comparator modules and set priorities
// Set priority to 7 & sub priority to 3
// Set CMP1 interrupt sub priority
// Clear the CMP1 interrupt flag
// Enable CMP1 interrupt
IPC7SET = 0x00070000;
IFS1CLR = 0x000000010;
IEC1SET = 0x000000010;
// Set CMP2 interrupt sub priority
// Clear the CMP2 interrupt flag
// Enable CMP2 interrupt
EXAMPLE 24-2:
COMPARATOR ISR CODE EXAMPLE
// Insert user code here
void__ISR(_COMPARATOR_2_VECTOR, ipl4)Cmp2_IntHandler(void)
{
// Insert user code here
IFS1CLR = 0x00000010; // Clear the CMP2 interrupt flag
}
void__ISR(_COMPARATOR_1_VECTOR, ipl4)Cmp1_IntHandler(void)
{
// Insert code user here
IFS1CLR = 0x00000008; // Clear the CMP1 interrupt flag
}
© 2008 Microchip Technology Inc.
Preliminary
DS61143E-page 547