XMOS入门 Topic is solved

技术交流
Post Reply
dianzihero
New User
Posts: 3
Joined: Fri Jun 09, 2017 2:53 am

XMOS入门

Post by dianzihero »

请教各位前辈,oneBit when pinsneq(x) :> x;是什么意思,编程手册上讲的看不懂。另外它与oneBit when pinsneq(x) :> void有什么区别。


View Solution
peter
XCore Addict
Posts: 230
Joined: Wed Mar 10, 2010 12:46 pm

Post by peter »

In the first case:
oneBit when pinsneq(x) :> x;

x will be updated with the new value of the port 'oneBit' that was not equal to the old value.

In the second case:
oneBit when pinsneq(x) :> void;

will read the value on the port when it is not equal to the current value and throw that value away. In the case of a 1-bit port it is easy to know what the value is because it will always be ~x.

However, in the case of a larger port (4-bit, 8-bit, 16-bit, 32-bit) then keeping the new value of the port will be a useful thing to do.
dianzihero
New User
Posts: 3
Joined: Fri Jun 09, 2017 2:53 am

Post by dianzihero »

thanks a lot
dianzihero
New User
Posts: 3
Joined: Fri Jun 09, 2017 2:53 am

Post by dianzihero »

我还想再问一下,oneBit when pinsneq(x) :> x;语句可以作为按键判断使用,oneBit when pinsneq(x) :> void有哪些用处
peter
XCore Addict
Posts: 230
Joined: Wed Mar 10, 2010 12:46 pm

Post by peter »

This is not often used with ports, however, it is very useful when using a timer and not wanting any clock drift:

tmr when timerafter(time) :> void:
time += period;

This gives a clock without drift, while doing:

tmr when timerafter(time) :> time:
time += period;

will result in a clock that drifts.
Post Reply