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
  • 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;
     }
    }
    

Reply
  • 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;
     }
    }
    

Children
No data