TCS Pune

PIC32 XC32 GPIO Interrupt

MPLAB XC32

PIC32 XC32 GPIO Interrupt

Handle a button interrupt on a 32-bit PIC target.

IDE: MPLAB X IDE with XC32 compiler and MCC/Harmony optionalBoard/MCU: PIC32 development board

Project files

Download project ZIP
Starter — main.c
#include <xc.h>
int main(void){ /* configure GPIO and interrupt */ while(1){} }
Completed — main.c
#include <xc.h>
#include <sys/attribs.h>
void __ISR(_EXTERNAL_0_VECTOR,IPL2SOFT) ext0(void){ IFS0CLR=_IFS0_INT0IF_MASK; LATBINV=1u<<0; }
int main(void){ ANSELBCLR=1u<<0; TRISBCLR=1u<<0; __builtin_enable_interrupts(); while(1){} }

Toolchain and dependencies

IDE requirements

MPLAB X IDE with XC32 compiler and MCC/Harmony optional

Compatible targets

PIC32 development board

Libraries/dependencies

  • Selected PIC32 device family pack

Serial output examples

Serial Monitor

External interrupt ready

Compiler-error explanations

unknown type name __ISR

Likely cause: XC32 interrupt support header is missing

Fix: Include sys/attribs.h

multiple definition of vector

Likely cause: Another handler uses the same vector

Fix: Keep one handler per interrupt vector

Submit your code

Log in to edit the starter files and submit your solution for instructor review.

Log in to submit
Ready when you are

Need help with your laptop or computer?

Send us the model and fault details. Start your repair request online or contact TCS Pune directly.

WA