Thursday, September 29, 2011

PIC32 pin change interrupt

The following is a quick snippet for interrupt on change pin
void __ISR(_CHANGE_NOTICE_VECTOR, ipl2) ChangeNotice_Handler(void) {            
	mPORTDRead(); //Need to read the port (see PIC32 datasheet)
	mCNClearIntFlag();
	//Your code...
}

And, in your initializing code:

mCNOpen(CN_ON | CN_IDLE_CON, CN13_ENABLE | CN14_ENABLE | CN15_ENABLE, CN_PULLUP_DISABLE_ALL); //See plib documentation and PIC32 datasheet
ConfigIntCN(CHANGE_INT_ON | CHANGE_INT_PRI_2);
INTEnableSystemMultiVectoredInt();	 

1 comment:

  1. Looks like you created this awhile but THANKS!! Helped a lot seeing how to setup a Pin Change Interrupt

    ReplyDelete