Sunteți pe pagina 1din 2

Change Notice Interrupts on the PIC 32 Processor using C32

I. Change notice interrupts are generated on selected enabled digital IO pins whenever the
voltage of the pin changes causing the processor to read a logic value that is different from
the previous reading of the PORT register.
II. A single interrupt vector is used for all CN interrupts. The interrupt does not tell you if the
pin went high or low; only that the condition on one of the selected pins has changed.
III. CN Interrupt flag must be cleared in software while servicing the interrupt.
IV. Input pin Treatment PIC32 Family Reference Manual Section 12 IO Ports, pg 29.

V. IO pins with CN interrupt capability


CN x Port CN x Port
CN0 RC13 CN10 RG8
CN1 RC14 CN11 RG9
CN2 RB0 CN12 RB15
CN3 RB1 CN13 RD4
CN4 RB2 CN14 RD5
CN5 RB3 CN15 RD6
CN6 RB4 CN16 RD7
CN7 RB5 CN17 RF4
CN8 RG6 BTN1 CN18 RF5
CN9 RG7 BTN2 CN19-CN21 NA
VI. Configuring pins for CN interrupts with out pull up resistors enabled
// CN8 detects BTN1 (RG6), CN9 detects BTN2 (RG7)

//Disable all interrupts

mINTDisableSystemMultiVectoredInt();

// Set pins for inputs

PORTSetDigitalIN((BIT_6|BIT_7));
PORTReadBits(IOPORT_G, (BIT_|BIT_7)); // Read pins to initialize

// Set for no internal pull up resistors on


mCNOpen((CN_ON|CN_FRZ_OFF),(CN8_ENABLE|CN9_ENABLE), 0);

// Set CN interrupt for priority level 1,


ConfigIntCN(CHANGE_INT_ON | CHANGE_INT_PRI_1);

// Enable milti vectored interrupts


INTEnableSystemMultiVectoredInt();

VII. CN ISR

void __ISR( _CHANGE_NOTICE_VECTOR, ipl1) DetButtons(void)


{

/* Code required for determining which button was pressed */

/* Code for required processing */

mCNClearIntFlag(); // Clear CN interrupt flag


asm ("nop"); // Suggested by text to clear pipeline
}

S-ar putea să vă placă și