enquiry on interrupt

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

enquiry on interrupt

1,193 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jx1 on Mon Aug 05 22:39:01 MST 2013
Hi everyone,

I am using a switch as interrupt. So whenever I turn the switch off, it will switch off my lamp.  My program does not seem to be working. How come when I turn the switch off, my lamp would not switch off? :~  Please take a look at the source code shown below.Thanks in advance!
volatile uint32_t pin9_counter = 0; 
typedef enum SysState
{
System_Start   = 0,
System_Idle,
System_Confirm,
System_Occupy,
System_Vacant
} SysState;

void PIOINT0_IRQHandler(void)
{
  uint32_t regVal;
  if (GPIOIntStatus( PORT0, 9 ))
  {
    pin9_counter = 1; 
  }
  else
      pin9_counter = 0;
      GPIOIntClear( PORT0, 9);
      return;
}

void DALI_Thread(void)
{
    bool dali_cmd;
    uint16_t forwardFrame;
    uint8_t  busy_led_state = 0;
    int lastTicks;

    DALI_Init();
    
GPIOInit();


GPIOSetDir (PORT0, 9, 0 );   
GPIOSetInterrupt( PORT0, 9, 0, 0, 1 ); 
GPIOIntEnable( PORT0, 9);

State = System_Start;

while(1)
{
switch (State)
{
case System_Start:
        pin9_counter = 1;
DALI_Send((0xFE << 8 ) + 0xFE); // Turn on the light 100% brightness
printf("System Start State\n");

if (pin9_counter == 0)
State = System_Idle;
    break;

/*========================================================================================================================*/
case System_Idle:

DALI_Send((0xFE << 8 ) + 0x00); 
printf("System Idle State\n");



if (pin9_counter == 1)
{
State = System_Start;
break;
}

Labels (1)
0 Kudos
Reply
1 Reply

1,170 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Tue Aug 06 23:42:53 MST 2013
Have you tried setting a breakpoint on PIOINT0_IRQHandler() and checking that you actually get the interrupt behaviour that you expect?

Regards,
LPCXPresso Support
0 Kudos
Reply