pinsneq case statement causing ET_ILLEGAL_RESOURCE

Technical questions regarding the XTC tools and programming with XMOS.
sflower
Member
Posts: 10
Joined: Thu Feb 16, 2012 6:27 pm

pinsneq case statement causing ET_ILLEGAL_RESOURCE

Post by sflower »

I'm having an issue with a modified ADAT Rx function. The modification allows a control token to be sent to the thread and the ADAT Rx function will then return.

Code: Select all

...
while(1)
{
  violation = word;

  select
  {
  case inct_byref (oChan, ct):
    return 1;
    break;
  case p when pinsneq(violation) :> int _:
    p :> word;
    fourBits = (word << 2) & mask;
    ...
    break;
  }
}
...
When the control token is sent the function exits correctly. But I then get a ET_ILLEGAL_RESOURCE error on the pinsneq line. It seems as if - even though this function has returned - it is still waiting for the event on port p.

Any ideas what I'm doing wrong?

Thanks!


User avatar
segher
XCore Expert
Posts: 844
Joined: Sun Jul 11, 2010 1:31 am

Post by segher »

Try setting a flag where you do the return now, and returning outside
of the select statement? It looks as if the event isn't disabled on the
port, and then when some other code enables events on the CPU the
event on the port fires; it has completely unexpected values in all
registers by then, so anything can happen (it probably does the input
in your code from something random).

Is it legal XC to return from a select? If so, smells like a compiler bug.
sflower
Member
Posts: 10
Joined: Thu Feb 16, 2012 6:27 pm

Post by sflower »

Hi segher,

Thanks for the suggestion. I've tried to set a flag and return from the function outside of the 'select' statement, but this didn't change anything.

According to this page it is legal to return from within a 'select'.

I'm currently on 11.11.1 of the compiler - I'm trying to check it with 12.2.0, but I seem to need a new version of XUD for that... Hopefully I'll have my hands on that tomorrow.

Any other thoughts much appreciated!
S
User avatar
Ross
XCore Expert
Posts: 968
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

Are you sure you are receiving the a control token on that channel? The same exception will be raised if a data token is received.

Do you have a small, complete test-case you can post?
sflower
Member
Posts: 10
Joined: Thu Feb 16, 2012 6:27 pm

Post by sflower »

Yes, the function exits as expected when the control token is received - and execution halts on the pinsneq case line. The problem is that the 'pinsneq' event gets triggered even after the function containing this select statement has returned.

I'll see if I can get this to happen with some simpler code...