Masking an input port for event driven use

Technical questions regarding the XTC tools and programming with XMOS.
User avatar
boeserbaer
Active Member
Posts: 51
Joined: Fri Jan 29, 2010 4:36 pm

Masking an input port for event driven use

Post by boeserbaer »

I am using P32A as a general purpose input port. I am also using LINKS A,B,C,D, P4A and P4C. When I try to use a select on pinsneq(oldValue) It is constantly triggered. Is there a good way to use a select on masked pin change?

For now I am using a timer within my select, and polling p32a then applying a mask, and then if there is a change, I act on it.

I would really like to use this in a cleaner fashion.

Regards Mike


User avatar
Andy
Respected Member
Posts: 279
Joined: Fri Dec 11, 2009 1:34 pm

Post by Andy »

Could you clarify what you mean by "constantly triggered"?
When I try to use a select on pinsneq(oldValue) It is constantly triggered.
User avatar
paul
XCore Addict
Posts: 169
Joined: Fri Jan 08, 2010 12:13 am

Post by paul »

The smaller ports take priority over the larger ports. The pins[n]eq() comparison is also on the whole port width, this means that whenever a part of the port changes to satisfy the event then the pins[n]eq() event will trigger. If If any of the small ports within the 32 bit port is an output then you will see the event fire every time you change the output of that port as the 32 bit port will see the change on its input.

Unfortunately you cannot mask off pins from this event.

The other options to do this are to use the required 1/4/8/16bit ports and just have events on those. You can wait for multiple events using select statements so could combine them if you wanted.

Hope that helps
Paul

On two occasions I have been asked, 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
User avatar
skoe
Experienced Member
Posts: 94
Joined: Tue Apr 27, 2010 10:55 pm

Post by skoe »

A bit late for the thread and possibly the wrong explanation, but it may be helpful for others: I noticed a similar behaviour when used a wide port and did not pull up or pull down the unised input pins. When pins are open (floating), their value may change very often, since they work like antennas. That's why they cause many events. Just connect them to GND to get peace.
User avatar
Woody
XCore Addict
Posts: 165
Joined: Wed Feb 10, 2010 2:32 pm

Post by Woody »

skoe wrote:Just connect them to GND to get peace.
Or enable the pullup/downs on that port:
set_port_pull_down(); // L1
set_port_pull_up(); // G4
User avatar
skoe
Experienced Member
Posts: 94
Joined: Tue Apr 27, 2010 10:55 pm

Post by skoe »

Woody wrote:Or enable the pullup/downs on that port
Arrgs. I missed that one. Thank you, very useful!