This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

MCB2300: GPIO Interrupt Problems

Hi everyone,

I'm new to programming with a MCB2300(LPC2378), and I'm having a little bit of trouble figuring out how to get the GPIO interrupts to work.

I'm trying to detect a rising edge on p2.6; if a rising edge is detected I turn on just p2.0, if it hasn't been detected i turn on just p2.1. I think that I am setting the gpio direction and enabling the interrupts correctly, but I can't get the desired behavior.

Here is my code:

int main(){

FIO2MASK0=0x00;
FIO2DIR0=0x03;
IO0_INT_EN_R=0x00000040;

while(1){
 if(IO_INT_STAT == 0x00000001)
        FIO2PIN0=1;
 else
        FIO2PIN0=2;
 }
}

thanks for any help that you can give me, sorry if i am making any really stupid/obvious errors.

Parents Reply Children
  • When using IO_INT_STATE, you shouldn't compare with a value. You should instead look for a specific bit and not assume that you know the state of any other bits.

    And you should make use of IO0IntClr or IO2IntClr to clear the interrupt state for the specific input pin after having detected the flank change.

  • Thanks for all of your help so far, I just got back from break and attempted to implement the changes that you suggested, and I wasn't successful. Here is the code that I'm using, can you take a look and see if you can spot the problem? I'm still just trying to see if the program is detecting a rising edge coming into pin 2.6.

    int main()
    {
     FIO2MASK0=0x00;
     FIO2DIR0=0x03;
     IO0_INT_EN_R=0x00000040;
     while(1)
     {
     if(IO0_INT_STAT_R &= 0x00000040)
     {
        FIO2PIN0=1;
        IO0_INT_CLR=0x00000040;
     }
     else
       FIO2PIN0=2;
     }
    }