Page 1 of 1

XMOS入门

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

Re: XMOS入门

Posted: Fri Jun 09, 2017 8:17 am
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.

Re: XMOS入门

Posted: Fri Jun 09, 2017 9:37 am
by dianzihero
thanks a lot

Re: XMOS入门

Posted: Fri Jun 09, 2017 10:47 am
by dianzihero
我还想再问一下,oneBit when pinsneq(x) :> x;语句可以作为按键判断使用,oneBit when pinsneq(x) :> void有哪些用处

Re: XMOS入门

Posted: Fri Jun 09, 2017 11:30 am
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.