Int1 strange problem with PIC18f87k22

Thread Starter

Picbuster

Joined Dec 2, 2013
1,045
Problem int0 and int2 are working but int1 is not.
Why is INT1 not working?

Picbuster

Part of interrupt routine
void interrupt ISR()
{

if (INTCON3bits.INT2IF) // working
{
INTCON3bits.INT2IF=0 ;
Xport1('&');
Display_Bl = Off; //led
}


if (INTCON3bits.INT1IF)
{
INTCON3bits.INT1IF=0; // not working

Xport1('#');

Display_Bl = On; // led
}

}
//================ end of interrupt

// ========== in main setup for interrupts

TRISB = 0b00001111; set inputs

INTCON3bits.INT1E=On;
INTCON3bits.INT1IE=On; // enable interrupt 1
INTCON3bits.INT2E=On;
INTCON3bits.INT2IE=On; // enable interrupt 2

INTCON3bits.INT1IF=0; // clear flag
INTCON3bits.INT2IF=0; // clear flag

INTCONbits.GIE=On; // global on
INTCONbits.PEIE=On;

while (1) //loop
{
__delay_ms(20); // just wait

}
//========================= test input b1 =========================
Find out if connection to chip or chip itself fails
INTCON3bits.INT1IE=Off;
disable interrupts for int1

while (1)

if (PORTBbits.RB1) // input RB1 is Working !!!
{

Xport1('@');
Display_Bl = On; // led

}


// hardware input and chip are working but INT1 when activated is remains dead.
 

Thread Starter

Picbuster

Joined Dec 2, 2013
1,045
as in it seems to be stuck in a constant interrupt loop or the interrupt just doesn't reset and the rest of the program works as expected.
Thank you for the reply.
Constant interrupt loop should stop all interrupts but they remain working.
(Int2 int0 timers etc).
However I will look into this you never know.

Picbuster
 

geekoftheweek

Joined Oct 6, 2013
1,099
Thank you for the reply.
Constant interrupt loop should stop all interrupts but they remain working.
(Int2 int0 timers etc).
However I will look into this you never know.

Picbuster
I thought that is what you meant, but wanted to be clear as I have enabled the wrong interrupts before and essentially put the program in a constant interrupted state due to not clearing the active interrupt.

Are you sure the interrupt pin is changing states? As a normal I/O pin it is defined as TTL with a low level of < .8 V while when configured as an interrupt it is a Schmidt Trigger input with a low level of <.2 V.

In other words PORTBbits.RB1 would switch to 0 at less than .8 V while the INT1 would not switch to 0 until less than .2 V.

Maybe switch the interrupt edge in your program while in the interrupt routine and see if it fires again when you switch to a low level?

That is what I would suspect short of failed interrupt logic in the PIC as everything else looks right so far.

Edit:

Just to clarify what I propose:
Code:
void interrupt ISR() {
     if (INTCON3bits.INT2IF)  { // working
          INTCON3bits.INT2IF=0 ;
          Xport1('&');
          Display_Bl = Off; //led
     }

     if (INTCON3bits.INT1IF)  {
          INTCON3bits.INT1IF=0; // not working

//--------------------------------------------------   test section
          if (INTCON2bits.INTEDG1) {  // check if triggered on low to high or high to low
               Xport1('#');  // low to high trigger
          }
          else {
                Xport1('$');  // high to low trigger
          }
          INTCON2bits.INTEDG1 = ~INTCON2bits.INTEDG1;  // modify trigger  -- my apologies if this could be written better as I normally use ASM
//--------------------------------------------------   end of test section

          Display_Bl = On; // led
     }
}
//================ end of interrupt
 
Last edited:
Top