Hello again. I'm trying to do a pushbutton example using external interrupts using INT0 for a pic18f2420. However, it seems like it doesn't activate even though I connect it to ground and vdd.
Rich (BB code):
#include <p18F2420.h>
#include <delays.h>
#include <portb.h>
#pragma config OSC = INTIO67
#pragma config WDT = OFF
#pragma config PBADEN = OFF
void ISR(void);
void CONFIG(void);
#pragma code isr = 0x08
#pragma interrupt ISR
void ISR(void)
{
if(INTCONbits.INT0IF)
{
PORTB |=0x02;
}
else
{
PORTB &=~0x02;
}
INTCONbits.INT0IF=0;
}
#pragma code
void main()
{
CONFIG();
while(1){}
}
void CONFIG(void)
{
TRISB=0x01; // Set everything but RB0 as output pins
PORTB=0x00;
INTCONbits.INT0IE=1; // Enable external interrupt on INT0
INTCON2bits.RBPU=0; // Pull ups on Portb are enable
INTCON2bits.INTEDG0=1; // Activates on raising edge
INTCONbits.GIE=1; // Enable global interrupts
}