PIC C18 External Interrupts INT0

Oct 31, 2010 0 Replies

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 #include #include



#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


Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required