Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

NAME: DHANISH KUMAR V

ROLL NO:211EE504

#include <p18f4550.h>

#define LED LATC

void External_Interrupt_Init();

void MSdelay(unsigned int);

void main()

OSCCON=0x72; /* Set internal oscillator to 8MHz*/

TRISC0=0; /* Make PORTC.0 as output*/

LED=0;

External_Interrupt_Init(); /* Initialize External Interrupt*/

while(1);

void External_Interrupt_Init()

TRISBbits.TRISB0=1; /* Make INT0 pin as an input pin*/

/* Also make PBADEN off in Configuration file or

clear ADON in ADCON0 so as to set analog pin as digital*/

INTCON2=0x00; /* Set Interrupt on falling Edge*/

INTCONbits.INT0IF=0;/* Clear INT0IF flag*/

INTCONbits.INT0IE=1;/* Enable INT0 external interrupt*/

INTCONbits.GIE=1; /* Enable Global Interrupt*/

void interrupt ISR()

LED = ~(LED); /* Toggle LED on interrupt*/

MSdelay(200);

INTCONbits.INT0IF=0;}

You might also like