How to use inuint_byref() ??

Technical questions regarding the XTC tools and programming with XMOS.
HILOSHI
New User
Posts: 3
Joined: Thu Feb 16, 2012 8:34 am

How to use inuint_byref() ??

Post by HILOSHI »

Dear All,

Regarding the below "select case" by using inuint_byref function, is there anyone could tell me in what
situation Task(B) will be perform ??

My question is there is no return value, why select know which procedure be executed.

Thanks everyone!!

Code: Select all

Select
{
  case inuint_byref(c_aud_ctl, tmp):
  {
    Task(A);
    break;
  }
  case inuint_byref(c_aud_ctl, tmp):
  {
    Task(B);
    break;
  }
}


User avatar
Bianco
XCore Expert
Posts: 754
Joined: Thu Dec 10, 2009 6:56 pm

Post by Bianco »

You should not use two operations on the same chanend (or resource in general) within a select statement.
User avatar
Ross
XCore Expert
Posts: 967
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

My question is there is no return value, why select know which procedure be executed.
The variable "tmp" is passed by reference (hence inuint_byref() ;) )
HILOSHI
New User
Posts: 3
Joined: Thu Feb 16, 2012 8:34 am

Post by HILOSHI »

Dear Bianco,

Yes, I know, sorry for the mistake.

I just wondering that afer "case" should be a "number", but I see inuint_byref have no return value,
so I do not know the program should "select" which "case".

Thanks for all
User avatar
Folknology
XCore Legend
Posts: 1274
Joined: Thu Dec 10, 2009 10:20 pm

Post by Folknology »

Select cases are a different animal from switch cases. unlike switch where branching is based on an int value, select cases are based on XS1 events. Events can be timer, port or channel events. for port or channel events they correspond to inputs becoming available. As such a given port or channel cannot appear in more than one case within a given select as the events would not be mutually exclusive. In your case you appear to be using one channel in 2 cases which will not work. There is a use that would appear to be able to support such coding when adding a input value guard to the channel/port select i.e. when a port or channel input equals a specific value, but this form of mutual exclusivity is not supported by the compiler and hence extending port/guard combinations across more than one case is also not possible, it would be an excellent addition to XC. Perhaps one of the Xmos folk can comment on such a possibility in future versions.

regards
Al
HILOSHI
New User
Posts: 3
Joined: Thu Feb 16, 2012 8:34 am

Post by HILOSHI »

Dear Folknology,

Thanks for your detail illustration, that is very useful.

Thanks.