Hello guys, Problem with the very basics. I am stuck with the external interrupt INT0 at RB0. Controller - PIC 18F47J53 MPLAB IDE, Microchip C Compiler I could not figure out what is wrong with the following code. Kindly help me out to make this work!! #include <p18f47j53.h> #include <delays.h> #include <portb.h> #pragma config OSC = HS #pragma config WDTEN = OFF #pragma config XINST = OFF void InterruptServiceHigh(void); void InterruptServiceLow(void); int x; void main(void) { INTCONbits.INT0IF = 0; INTCONbits.INT0IE = 1; INTCON2bits.INTEDG0 = 1; INTCON2bits.RBPU = 0; //EnablePullups(); TRISE = 0; TRISBbits.TRISB0 = 1; RCONbits.IPEN = 1; INTCONbits.GIE = 1; INTCONbits.PEIE = 1; while(1) { PORTE = 0x01; } } // High priority interrupt vector #pragma code InterruptVectorHigh = 0x08 void InterruptVectorHigh(void) { _asm goto InterruptServiceHigh _endasm } // Low priority interrupt vector #pragma code InterruptVectorLow = 0x18 void InterruptVectorLow(void) { _asm goto InterruptServiceLow _endasm } // Interrupt Service Routine // Interrupt pragma for high priority #pragma code #pragma interrupt InterruptServiceHigh void InterruptServiceHigh() { // function statements if(INTCONbits.INT0IF) { x = 0; while(x <= 2) { PORTE = 0x01; Delay10KTCYx(120); // Delay of 1 sec with 12 MHz PORTE = 0x02; Delay10KTCYx(120); x++; } INTCONbits.INT0IF = 0; } // return from high priority interrupt } // Interrupt pragma for low priority #pragma code #pragma interrupt InterruptServiceLow void InterruptServiceLow() { // function statements // return from low priority interrupt } --------------------------------------- Posted through http://www.EmbeddedRelated.com
PIC C18 External Interrupts INT0
Started by ●October 31, 2010