Author Topic: PIC18F external interrupts not triggering  (Read 743 times)

0 Members and 1 Guest are viewing this topic.

Offline newtekuserTopic starter

  • Frequent Contributor
  • **
  • Posts: 449
  • Country: us
PIC18F external interrupts not triggering
« on: October 21, 2024, 02:14:20 am »
Using PIC18F46K40 and in my simple test code, pin RA4 is connected to an LCD backlight which should be turned on when pressing the button connected to RB0 using external interrupt, but it never triggers. Very similar approach works just fine on PIC16F887. Is there something I missed in the setup? The wiring is exactly the same as I'm just swapping MCUs on the breadboard.

LATAbits.LATA4 = 0;
INTCONbits.INT0EDG = 0;
PIR0bits.INT0IF = 0;
PIE0bits.INT0IE = 1;
INTCONbits.GIE = 1;
INTCONbits.PEIE = 1;

void __interrupt() isr(void)
{
if (PIR0bits.INT0IF == 0)
    {     
        LATAbits.LATA4 = 1;
        PIR0bits.INT0IF = 0;
    }
}
 

Offline newtekuserTopic starter

  • Frequent Contributor
  • **
  • Posts: 449
  • Country: us
Re: PIC18F external interrupts not triggering
« Reply #1 on: October 21, 2024, 04:08:54 am »
My bad, wasn't checking for the interrupt correctly. The fix was:

Code: [Select]
if (PIR0bits.INT0IF)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf