You are currently viewing How to Interface Interrupts with dsPIC30F4011 – dsPIC Development Board

How to Interface Interrupts with dsPIC30F4011 – dsPIC Development Board

Spread the love

The DsPIC30F4011 Development Board is specifically designed to help students to master the required skills in the area of embedded systems. The kit is designed in such way that all the possible features of the microcontroller will be easily used by the students. The kit supports in system programming (ISP) which is done through USB port.

Microchipโ€™s dsPIC30F (dsPIC30F4011), Development Kit is proposed to smooth the progress of developing and debugging of various designs encompassing of High speed 16-bit Microcontrollers.

External Interrupts

An interrupt caused by an external source such as the computer operator, external sensor or monitoring device, or another computer. Interrupts are special events that require immediate attention.

Interfacing External Interrupts

Fig. 1 shows how to interface the External Interrupt to microcontroller. Interrupts cause the processor to cease the running task to serve a special task for which the interrupt event had occurred. After the special task is over, the processor resumes performing the original task.

The processor can also serve these events by polling method. But polling is an inefficient technique as compared to interrupts. In the polling method, the processor has to continuously wait for the event signal. Thus it always remains busy using extra resources.

Interface Interrupts with dsPIC30F4011 dsPIC Development Board
Fig. 1 Interfacing External Interrupts to Microcontroller

Interfacing External Interrupts with dsPIC30F4011

We now want to display some messages in PC when occur an external interrupt signal in DsPIC30F4011 Development Board. The Interrupt signal is occurred by using switches. When the switch is pressed to LOW, then the external interrupt is occurred.

The Vectored Interrupt Controller (VIC) takes 32 interrupt request inputs and programmable assigns them into 3 categories, FIQ, vectored IRQ, and non-vectored IRQ.

The DsPIC30F4011 Development Board has two numbers of External Interrupts, connected with I/O Port lines (PORTE.8, PORTD.0 & PORTD.1) as switches.

Pin Assignment with dsPIC30F4011

pin assignment for Interface Interrupts with dsPIC30F4011 dsPIC Development Board

Circuit Diagram to Interface Ext-Interrupt with dsPIC

circuit diagram for Interface Interrupts with dsPIC30F4011 dsPIC Development Board

Source Code

The Interfacing External Interrupt with dsPIC program is very simple and straight forward, that accessed by using switches. When the two external interrupts occurring, some messages are displayed in PC through serial port at 9600 baud rate. The C program is written in Mplab software & compiled the code by using Microchip C30 Compiler.

C Program to interface Ext-Interrupt with dsPIC30F4011

#include "p30f4011.h"
#define XTFREQ 20000000
#define FOSC XTFREQ/4
#define BAUDRATE 9600
#define BRGVAL ((FOSC/BAUDRATE)/16)-1
#define INT0 IFS0bits.INT0IF
#define INT1 IFS1bits.INT1IF
#define INT2 IFS1bits.INT2IF void Interrupt_init(void);
void DelayMs(unsigned int);
int main()
ADPCFG = 0xffff;
TRISB = 0x0000;
return 0;
void Interrupt_init(void)
INTCON1 = 0x0000;
INTCON2 = 0x0000;
IFS0 = 0x0000;
IFS1 = 0x0000;
IEC0 = 0x0001;
IEC1 = 0x0081;
IPC0 = 0x0007;
IPC4 = 0x0006;
IPC5 = 0x5000;
void _ISR _INT0Interrupt(void)
INT0 = 0;
LATBbits.LATB3 ^=1;
void _ISR _INT1Interrupt(void)
INT1 = 0;
LATBbits.LATB4 ^=1;
void _ISR _INT2Interrupt(void)
INT2 = 0;
LATBbits.LATB5 ^=1;
void DelayMs(unsigned int Ms)
unsigned int delay_cnst;
for(delay_cnst = 0;
delay_cnst <276;delay_cnst++);

To compile the above C code you must need the Mplab software & Microchip C30 Compiler. They must be properly set up and a project with correct settings must be created in order to compile the code. To compile the above code, the C file must be added to the project.

In Mplab, you want to develop or debug the project without any hardware setup. You must compile the code for generating HEX file. In debugging Mode, you want to check the port output without DsPIC30F4011 Development Board.

The PICKIT2 software is used to download the hex file into your microcontroller IC dsPIC30F4011 through USB.

Testing the External Interrupts with dsPIC30F4011

Give +9V power supply to DsPIC30F4011 Development Board; the serial cable is connected between the DsPIC30F4011 Development Board and PC. Open the Hyper Terminal screen, select which port you are using and set the default settings. Now the screen should show which external interrupt is selected.

When you pressed the external interrupt key, the screen should update which interrupt is now pressed. The Interrupts are controlled by using switches. If any data is not coming in Hyper Terminal, then you just check the serial cable is working or not. Otherwise you just check the code with debugging mode in Mplab. If you want to see more details about debugging just see the videos in below link.

โ˜žHow to create & Debug a Project in Mplab using dsPIC30F.

General Information

โ˜žFor proper working use the components of exact values as shown in Circuit file. Use new components.

โ˜žSolder everything in a clean way. A major problem arises due to improper soldering, solder jumps and loose joints.

โ˜žUse the exact value crystal shown in schematic.

โ˜žMore instructions are available in following articles,

dSPIC Development board

Interfacing UART with dsPIC30F4011.

How to Interface Keypad with dsPIC30F4011 dsPIC Development Board

User Manual of DSPIC Development Board

Creating & Debugging a Project in MPLAB using dsPIC30F

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.