XMOS入门 Topic is solved
-
- New User
- Posts: 3
- Joined: Fri Jun 09, 2017 2:53 am
XMOS入门
请教各位前辈,oneBit when pinsneq(x) :> x;是什么意思,编程手册上讲的看不懂。另外它与oneBit when pinsneq(x) :> void有什么区别。
View Solution
-
- XCore Addict
- Posts: 230
- Joined: Wed Mar 10, 2010 12:46 pm
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.
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.
-
- New User
- Posts: 3
- Joined: Fri Jun 09, 2017 2:53 am
thanks a lot
-
- New User
- Posts: 3
- Joined: Fri Jun 09, 2017 2:53 am
我还想再问一下,oneBit when pinsneq(x) :> x;语句可以作为按键判断使用,oneBit when pinsneq(x) :> void有哪些用处
-
- XCore Addict
- Posts: 230
- Joined: Wed Mar 10, 2010 12:46 pm
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.
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.