enquiry on interrupt

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

enquiry on interrupt

175 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jx1 on Tue Aug 06 20:31:35 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;
}
0 Kudos
1 Reply

168 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Tue Aug 06 23:44:12 MST 2013
Why have you posted the same question again in a new thread?

Please just stick to one thread !....
http://www.lpcware.com/content/forum/enquiry-interrupt

Regards,
LPCXpresso Support
0 Kudos