Simple Interrup Example MPLAB

The following code will run on MX320 32-bit microcontroller. Taken from “Programming 32-bit Micrcontroller in C”.

Note that certain lines were modified to make it work.

** Single Interrupt vector test

#include <p32xxxx.h>
#include <peripheral\int.h>
#include <plib.h>
#define _T2IE IEC0bits.T2IE
#define _T2IF IFS0bits.T2IF
#define _T2IP IPC2bits.T2IP
int count;
void __ISR( 0, ipl1) InterruptHandler( void)
_T2IF = 0;
} // interrupt handler
// 1. init timers
PR2 = 15;
T2CON = 0x8030;
// 2. init interrupts
_T2IP = 1;
_T2IE = 1;
// 3. main loop
while( 1);
} // main

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s