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

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
The VAR Block
In the
used by the
The Main Method
We modified the
encased in a
Propeller Assembly code. In this case, we entered
first parameter, and
to run the
time stack space. The
variable following it.
To run Spin code, the new cog needs some run-time workspace, called “stack space,” where
it can store temporary things like return addresses, return values, intermediate expression
values, etc. We chose to reserve 9 longs of space (36 bytes), and passed the address of that
space as
depending on the Spin code being executed, but we’ll discuss those details later. For now,
rest assured that 9 longs of space is enough for our
Compile and download Output.spin. You should see that the LEDs on P16 and P17 now
simultaneously blink at different rates, 5 times and 10 times, respectively. This is because we
now have two cogs running simultaneously; one toggles P16 while the other toggles P17.
Here’s how it works: Cog 0 starts executing our application’s
Main
the parameters
continues on with the second line of the
parameters
P17 while Cog 1 executes
expired, they each terminate due to lack of code. Cog 1 terminates the moment it finishes
Toggle
terminate earlier than Cog 0 in this case.
uses the
VAR
. Cog 0 finishes
COGNEW
block we defined an array of longs,
Toggle
(17, 2_000_000, 20)
Main
COGNEW
COGNEW
’s second parameter,
(16, 3_000_000, 10)
method.
Main
method and will use the memory starting at the address of
@Stack
command. The
command to activate a new cog (Cog 1) to run the
@
method’s first line such that its original code, the call to
Toggle
is the Symbol Address operator; it returns the actual address of the
Toggle
for its second parameter. This means
, returns to
passed to it. Ultimately, Cog 0 is left executing
on P16, simultaneously. When their individual tasks have
COGNEW
@Stack
passed to it. While Cog 1 is starting up, Cog 0
Main
command starts a new cog to run either Spin or
Main
. How much stack space is needed? It varies
Stack
method, the direct call to
and then terminates. Cog 1 happens to
Toggle
Toggle(16, 3_000_000, 10)
, which is 9 elements in length. This is
method.
Propeller Manual v1.0 · Page 107
Main
COGNEW
method. The first line of
Toggle
will start a new cog
Toggle
Stack
, for
method with
Toggle
Toggle
COGNEW
with the
for run-
, is
on
’s

Related parts for 122-32000