122-32000 Parallax Inc, 122-32000 Datasheet - Page 190
122-32000
Manufacturer Part Number
122-32000
Description
MANUAL PROPELLER
Manufacturer
Parallax Inc
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
- Current page: 190 of 438
- Download datasheet (5Mb)
Spin Code (Syntax 1)
To run a Spin method in another cog, the
parameters, and a pointer to some stack space. For example:
VAR
PUB Main | X
PUB Square(XAddr)
This example shows two methods,
endlessly, then
cog, takes the value of
million cycles before it does it again. More explanation follows, but the result is that
out as 2, and the second cog, running
finally to 0 (it overflowed 32 bits), all independent of the first cog which may be checking the
value of
The
new cog, with
Square(@X)
address of the
space reserved for the new cog. When a cog is started to run Spin code, it needs some stack
space where it can store temporary data such as call stacks, parameters and intermediate
expression results. This example only requires 6 longs of stack space for proper operation
(see the “Stack Length” object in the Propeller Library for more information).
After the
method and the second is starting to run the
Page 190 · Propeller Manual v1.0
long SqStack[6]
X := 2
cognew(Square(@X), @SqStack) 'Launch square cog
<check X here>
'Square the value at XAddr
repeat
Main
long[XAddr] *= long[XAddr] ' Square value, store back
waitcnt(2_000_000 + cnt)
X
COGNEW
method declares a local variable,
or performing some other task.
, is the Spin method to run and its required parameter; in this case we pass it the
– Spin Language Reference
X
COGNEW
Main
variable. The second parameter of
command is executed, two cogs are running; the first is still running the
can monitor the results in the
, to run the
XAddr
, squares it and stores the result back into
Square
Main
Square
and
method in a separate cog.
X
'Stack space for Square cog
'Initialize X
'Loop here and check X
'Repeat the following endlessly
' Wait 2 million cycles
, that is set to 2 in its first line. Then
Square
, iteratively sets
COGNEW
Square
.
X
COGNEW
command needs the method name, its
Main
method. Despite the fact that they are
variable.
starts another cog that runs
,
@SqStack
X
to 4, 16, 256, 65536 and then
Square
COGNEW
, is the address of stack
XAddr
, being run by another
’s first parameter,
, then waits for 2
Main
X
starts a
Square
starts
Main
Related parts for 122-32000
Image
Part Number
Description
Manufacturer
Datasheet
Request
R
Part Number:
Description:
MANUAL FOR SUMOBOT
Manufacturer:
Parallax Inc
Datasheet:
Part Number:
Description:
GUIDE STUDENT PROCESS CONTROL
Manufacturer:
Parallax Inc
Datasheet:
Part Number:
Description:
GUIDE STUDENT SMART SENSORS
Manufacturer:
Parallax Inc
Datasheet:
Part Number:
Description:
LEAD WIRES FLYING CABLE III/IV
Manufacturer:
Xilinx Inc
Datasheet:
Part Number:
Description:
BOARD ADAPTER AND FLY LEADS
Manufacturer:
Xilinx Inc
Datasheet:
Part Number:
Description:
PLATFORM CABLE USB II
Manufacturer:
Xilinx Inc
Datasheet:
Part Number:
Description:
KIT STARTER COOLRUNNER-II BUNDLE
Manufacturer:
Xilinx Inc
Datasheet:
Part Number:
Description:
Microcontroller Modules & Accessories DISCONTINUED BY PARALLAX
Manufacturer:
Parallax Inc
Part Number:
Description:
Microcontroller Modules & Accessories DISCONTINUED BY PARALLAX
Manufacturer:
Parallax Inc
Part Number:
Description:
BOOK UNDERSTANDING SIGNALS
Manufacturer:
Parallax Inc
Datasheet:
Part Number:
Description:
BOARD EXPERIMENT+LCD NX-1000
Manufacturer:
Parallax Inc
Datasheet:
Part Number:
Description:
IC MCU 2K FLASH 50MHZ SO-18
Manufacturer:
Parallax Inc
Datasheet: