122-32000 Parallax Inc, 122-32000 Datasheet - Page 201

MANUAL PROPELLER

122-32000

Manufacturer Part Number
122-32000
Description
MANUAL PROPELLER
Manufacturer
Parallax Inc
Datasheets

Specifications of 122-32000

Accessory Type
Manual
Lead Free Status / RoHS Status
Lead free / RoHS Compliant
For Use With/related Products
Propeller Education (PE) Kit
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
CON
PUB Blink
The above two examples do exactly the same thing: their
X+200
block’s
expressions used in each example’s
place. For this reason, it may not make sense to define additional constants in the
for things like
in the run-time code, as in Example 1, but that entire expression is unfortunately evaluated at
run time, requiring extra time and code space.
The
time-use constant expression to a single, static value, saving code space and speeding up
execution. In Example 1, the
2’s
space. Note that the “
directive’s parentheses; this is because
CNT
If a constant needs to be used in more than one place in code, it is better to define it in the
block so it is defined only once and the symbol representing it can be used multiple times.
X = 500
Y = 2500
!outa[0]
waitcnt(constant(X+200) + cnt) 'exp w/compile & run-time parts
!outa[0]
waitcnt(constant((X+Y)/2) + cnt)'exp w/compile & run-time parts
, page 184) so its value cannot be resolved at compile time.
Blink
CONSTANT
cycles, toggle P0 again and wait for
X
and
method, with the addition of the
Y
directive is perfect for this situation, because it completely resolves each one-
X+200
symbols may need to be used in multiple places within the object, the
and
+ cnt
(X+Y)/2
” portion of the expressions are not included within the
Blink
. There is nothing wrong with putting the expressions right
4: Spin Language Reference –
method consumes 33 bytes of code space while Example
Blink
cnt
method might only need to be used in that one
(X+Y)/2
is a variable (the System Counter variable; see
CONSTANT
cycles before returning. While the
directives, only requires 23 bytes of
Blink
Propeller Manual v1.0 · Page 201
methods toggle P0, wait for
CON
CONSTANT
WAITCNT
block
CON
CON

Related parts for 122-32000