About event handling in startkit device Topic is solved

If you have a simple question and just want an answer.
User avatar
jeevanicherukuri
Member++
Posts: 17
Joined: Fri Dec 26, 2014 4:41 pm

About event handling in startkit device

Post by jeevanicherukuri »

I wrote a program related to Event Handling. The program means that - whenever button is pressed, led(B2)  must glow in STARTKIT.
 
I took the condition  "pressing button" inside case , which leads to the occurring of event(glowing led as the event).
 
1 error ccurred at case statement(parse error before '(' token.          ).
 
What is this error?
 
PROGRAM CODE:
 
#include <xs1.h>
#include <timer.h>
#include<stdio.h>
port p=XS1_PORT_32A;
int led=~(1<<11);
int delay=1000;
 
int main()
{   
 unsigned int b=0x00000000;
    select
    {
        case b when (~b & 0x0000001):
           p:> b;
           p<:~(1<<11);
          printf("event occurred");
        break;
        return 0;
    }
}
 
View Solution
srinie
XCore Addict
Posts: 158
Joined: Thu Mar 20, 2014 8:04 am

Post by srinie »

hi,

select statement enables the events on the resources (channels, timers,) and waits for them to occur.

in that context,  "case b when (~b & 0x0000001):"  does not sound correct; pls double check what you want to achieve here.

 

 'return 0;'  //to be moved out of the select block isn't it!?

Guest

Post by Guest »

You should do something like this:

#include <xs1.h>
#include <timer.h>
#include<stdio.h>
 
port p=XS1_PORT_32A;
int led=~(1<<11);
int delay=1000;
 
int app()
{   
 unsigned int b=0x00000000;
  unsigned port_value;
  p:> port_value;
  while(1)
 {
    select
    {
        case p when pinsneq(port_value & 0x0000001):> port_value:
           p:> b;
           p<:~(1<<11);
          printf("event occurred");
        break;
    }
 }
 return 0;
}
int main()

{

  par

  {

    app();

  }

  return 0;

}