lpcware

Interrupt lpc1343

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by xOrElse on Thu Jul 05 04:19:59 MST 2012
Hello,
I'm havnig a little problem with interrupt.

http://4.bp.blogspot.com/-scoXFGGR5qI/T_VL8_wbFTI/AAAAAAAAAMk/3GYHfmxStXk/s1600/Untitled.jpg

In this picture is how I connect all wires. Don't look the chip, it's just so you can see where is the button. In reality chip is: lpc1343.

This are all connections http://3.bp.blogspot.com/-QqWyBNYHbxY/T_VNMUDh6dI/AAAAAAAAAMs/bpmduXOdscI/s1600/P7050004.JPG
In this picture you can see one LED, it's just so I could see if the interrupt is working right.
The program is always in one loop while (1), where the led is OFF, and when I press the button the led should be ON, and it should be always ON. But it's not, like the chip doesn't recognize interrupt.

LED is working perfectly, but I have problems whit this button, I'm not shure in the scheme anymore. (btw. that same scheme is working just fine on PIC18f456)

This is my code for main program:


int main (void)
{
  GPIOInit();

  /* use port0_1 as input event, interrupt test. */
  GPIOSetDir( PORT2, 4, 0 );
  GPIOSetDir( PORT2, 1, 1 );
  /* port0_1, single trigger, active high. */
  GPIOSetInterrupt( PORT2, 4, 0, 0, 0 );
  GPIOIntEnable( PORT2, 4 );

  while( 1 ){
      GPIOSetValue( PORT2, 1, 0 );
      while (1){
      if (val!=0){
          GPIOSetValue( PORT2, 1, 1 );
      }}
  };
}
This is interrupt code:


void PIOINT2_IRQHandler(void)
{
  uint32_t regVal;

  val=1;
  gpio2_counter++;
  regVal = GPIOIntStatus( PORT2, 0 );
  if ( regVal )
  {
    p2_1_counter++;
    GPIOIntClear( PORT2, 0 );
  }       
  return;
}
val is global variable, so that I can use in all program...
Everything else is pretty much the same as their example on offical site...

Please help me, I've been doing it for so long....

Outcomes