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

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
terminates; the cog stops and the Propeller goes into a low-power mode until the next reset or
power cycle.
Don’t be confused by the look of the code. The two methods,
right after another, but they are treated as distinct routines starting at their
declarations and ending at the next block declaration or the end of the source code, whichever
comes first. In other words, the Propeller knows that the
Main
Also note we’ve still used just one cog in our example, and the entire application is executed
serially: first blink P16, then stop, blink P17, then stop. We’ll begin to use multiple cogs in
the next exercise.
Exercise 5: Output.spin – Parallel Processing
In exercises 1 through 4 we’ve used just one cog to process the application; it toggles P16
only, then stops and toggles P17 only, then terminates. This is called “serial processing.”
Suppose, however, that we want to do things in parallel; simultaneously toggling pins 16 and
17, each at different rates and for different finite periods. Tasks like this can certainly be
done with serial processing and clever programming but it is easier with parallel processing
by having the Propeller activate two cogs. Look at the following example and edit your code
to match. We added a variable block (
{{Output.spin
Toggle two pins, one after another simultaneously.}}
VAR
PUB Main
PUB Toggle(Pin, Delay, Count)
{{Toggle Pin, Count times with Delay clock cycles in between.}}
Page 106 · Propeller Manual v1.0
long Stack[9]
cognew(Toggle(16, 3_000_000, 10), @Stack)
Toggle(17, 2_000_000, 20)
dira[Pin]~~
repeat Count
method’s executable code.
!outa[Pin]
waitcnt(Delay + cnt)
VAR
'Stack space for new cog
'Set I/O pin to output direction
'Repeat for Count iterations
' Toggle I/O Pin
' Wait for Delay cycles
) and made a slight change to the
Toggle
Main
'Toggle P17 twenty…
'Toggle P16 ten…
method is not a part of the
and
Toggle
Main
, are shown one
method.
PUB
block

Related parts for 122-32000