Propeller Manual v1.01
Propeller Manual v1.01
Versi on 1.01
WARRANTY
Parallax Inc. warrants its products against defects in materials and workmanship for a period of 90 days from receipt of product.
If you discover a defect, Parallax Inc. will, at its option, repair or replace the merchandise, or refund the purchase price. Before
returning the product to Parallax, call for a Return Merchandise Authorization (RMA) number. Write the RMA number on the
outside of the box used to return the merchandise to Parallax. Please enclose the following along with the returned merchandise:
your name, telephone number, shipping address, and a description of the problem. Parallax will return your product or its
replacement using the same shipping method used to ship the product to Parallax.
14-DAY MONEY BACK GUARANTEE
If, within 14 days of having received your product, you find that it does not suit your needs, you may return it for a full refund.
Parallax Inc. will refund the purchase price of the product, excluding shipping/handling costs. This guarantee is void if the
product has been altered or damaged. See the Warranty section above for instructions on returning a product to Parallax.
COPYRIGHTS AND TRADEMARKS
This documentation is copyright 2006 by Parallax Inc. By downloading or obtaining a printed copy of this documentation or
software you agree that it is to be used exclusively with Parallax products. Any other uses are not permitted and may represent a
violation of Parallax copyrights, legally punishable according to Federal copyright or intellectual property laws. Any duplication
of this documentation for commercial uses is expressly prohibited by Parallax Inc. Duplication for educational use is permitted,
subject to the following Conditions of Duplication: Parallax Inc. grants the user a conditional right to download, duplicate, and
distribute this text without Parallax's permission. This right is based on the following conditions: the text, or any portion thereof,
may not be duplicated for commercial use; it may be duplicated only for educational purposes when used solely in conjunction
with Parallax products, and the user may recover from the student only the cost of duplication.
This text is available in printed format from Parallax Inc. Because we print the text in volume, the consumer price is often less
than typical retail duplication charges.
Parallax, Propeller Spin, and the Parallax and Propeller Hat logos are trademarks of Parallax Inc. BASIC Stamp, Stamps in
Class, Boe-Bot, SumoBot, Toddler, and SX-Key are registered trademarks of Parallax, Inc. If you decide to use any trademarks
of Parallax Inc. on your web page or in printed material, you must state that (trademark) is a (registered) trademark of Parallax
Inc. upon the first appearance of the trademark name in each printed document or web page. Other brand and product names
herein are trademarks or registered trademarks of their respective holders.
ISBN 1-928982-38-7
DISCLAIMER OF LIABILITY
Parallax Inc. is not responsible for special, incidental, or consequential damages resulting from any breach of warranty, or under
any legal theory, including lost profits, downtime, goodwill, damage to or replacement of equipment or property, or any costs of
recovering, reprogramming, or reproducing any data stored in or used with Parallax products. Parallax Inc. is also not
responsible for any personal damage, including that to life and health, resulting from use of any of our products. You take full
responsibility for your Propeller microcontroller application, no matter how life-threatening it may be.
INTERNET DISCUSSION LISTS
We maintain active web-based discussion forums for people interested in Parallax products. These lists are accessible from
www.parallax.com via the Support Discussion Forums menu. These are the forums that we operate from our web site:
Propeller chip This list is specifically for our customers using Propeller chips and products.
BASIC Stamp This list is widely utilized by engineers, hobbyists and students who share their BASIC Stamp
projects and ask questions.
Stamps in Class
Created for educators and students, subscribers discuss the use of the Stamps in Class
curriculum in their courses. The list provides an opportunity for both students and educators to ask questions
and get answers.
Parallax Educators A private forum exclusively for educators and those who contribute to the development of
Stamps in Class. Parallax created this group to obtain feedback on our curricula and to provide a place for
educators to develop and obtain Teachers Guides.
Robotics Designed for Parallax robots, this forum is intended to be an open dialogue for robotics enthusiasts.
Topics include assembly, source code, expansion, and manual updates. The Boe-Bot
, Toddler
, SumoBot
,
HexCrawler and QuadCrawler robots are discussed here.
SX Microcontrollers and SX-Key Discussion of programming the SX microcontroller with Parallax assembly
language SX Key
programming language.
ERRATA
While great effort is made to assure the accuracy of our texts, errors may still exist. If you find an error, please let us know by
sending an email to [email protected]. We continually strive to improve all of our educational materials and documentation,
and frequently revise our texts. Occasionally, an errata sheet with a list of known errors and corrections for a given text will be
posted to our web site, www.parallax.com. Please check the individual product pages free downloads for an errata file.
SUPPORTED HARDWARE, FIRMWARE AND SOFTWARE
This manual is valid with the following hardware, software, and firmware versions:
Hardware Software Firmware
P8X32A-D40
P8X32A-Q44
P8X32A-M44
Propeller Tool v1.0 P8X32A v1.0
CREDITS
Authorship: Jeff Martin. Format & Editing, Stephanie Lindsay.
Cover Art: Jen Jacobs; Technical Graphics: Rich Allred; with many thanks to everyone at Parallax Inc.
Table of Contents
Propeller Manual v1.0 Page 5
PREFACE ............................................................................................................................... 12
CHAPTER 1 : INTRODUCING THE PROPELLER CHIP....................................................... 13
CONCEPT ............................................................................................................................. 13
PACKAGE TYPES................................................................................................................... 14
PIN DESCRIPTIONS................................................................................................................ 15
SPECIFICATIONS ................................................................................................................... 16
HARDWARE CONNECTIONS.................................................................................................... 17
BOOT UP PROCEDURE .......................................................................................................... 18
RUN-TIME PROCEDURE......................................................................................................... 18
SHUTDOWN PROCEDURE....................................................................................................... 19
BLOCK DIAGRAM................................................................................................................... 20
SHARED RESOURCES............................................................................................................ 22
SYSTEM CLOCK .................................................................................................................... 22
COGS (PROCESSORS) ........................................................................................................... 22
HUB ..................................................................................................................................... 24
I/O PINS ............................................................................................................................... 26
SYSTEM COUNTER................................................................................................................ 27
CLK REGISTER..................................................................................................................... 28
LOCKS.................................................................................................................................. 30
MAIN MEMORY...................................................................................................................... 30
MAIN RAM........................................................................................................................... 31
MAIN ROM........................................................................................................................... 32
CHARACTER DEFINITIONS...................................................................................................... 32
LOG AND ANTI-LOG TABLES................................................................................................... 34
SINE TABLE .......................................................................................................................... 34
BOOT LOADER AND SPIN INTERPRETER.................................................................................. 34
CHAPTER 2 : USING THE PROPELLER TOOL.................................................................... 35
CONCEPT ............................................................................................................................. 35
SCREEN ORGANIZATION........................................................................................................ 37
MENU ITEMS ......................................................................................................................... 45
File Menu........................................................................................................................ 45
Edit Menu ....................................................................................................................... 46
Run Menu....................................................................................................................... 47
Help Menu ...................................................................................................................... 48
FIND/REPLACE DIALOG.......................................................................................................... 49
OBJECT VIEW ....................................................................................................................... 52
OBJECT INFO........................................................................................................................ 55
CHARACTER CHART .............................................................................................................. 58
VIEW MODES, BOOKMARKS AND LINE NUMBERS..................................................................... 61
View Modes.................................................................................................................... 61
Bookmarks...................................................................................................................... 63
Table of Contents
Page 6 Propeller Manual v1.0
Line Numbers.................................................................................................................. 64
EDIT MODES ......................................................................................................................... 65
Insert and Overwrite Modes............................................................................................ 65
Align Mode...................................................................................................................... 66
BLOCK SELECTION AND SELECTION MOVING........................................................................... 68
INDENTING AND OUTDENTING................................................................................................. 69
Single Lines..................................................................................................................... 70
Multiple Lines .................................................................................................................. 71
BLOCK-GROUP INDICATORS................................................................................................... 74
SHORTCUT KEYS................................................................................................................... 75
Categorical Listings......................................................................................................... 75
Listing by Key.................................................................................................................. 80
CHAPTER 3 : PROPELLER PROGRAMMING TUTORIAL.................................................... 85
CONCEPT.............................................................................................................................. 85
PROPELLER LANGUAGES (SPIN AND PROPELLER ASSEMBLY) .................................................. 86
PROPELLER OBJECTS............................................................................................................ 86
Quick Review: Intro......................................................................................................... 91
EXERCISE 1: OUTPUT.SPIN OUR FIRST OBJECT ................................................................... 92
Downloading to RAM vs. EEPROM................................................................................ 93
Quick Review: Ex 1......................................................................................................... 96
COGS (PROCESSORS) ........................................................................................................... 97
EXERCISE 2: OUTPUT.SPIN - CONSTANTS ............................................................................... 98
BLOCK DESIGNATORS............................................................................................................ 99
EXERCISE 3: OUTPUT.SPIN - COMMENTS .............................................................................. 100
Quick Review: Ex 2 & 3 ................................................................................................ 103
EXERCISE 4: OUTPUT.SPIN PARAMETERS, CALLS, AND FINITE LOOPS ................................. 104
EXERCISE 5: OUTPUT.SPIN PARALLEL PROCESSING........................................................... 106
Quick Review: Ex 4 & 5 ................................................................................................ 109
EXERCISE 6: OUTPUT.SPIN & BLINKER1.SPIN USING OUR OBJECT...................................... 110
THE OBJECT VIEW............................................................................................................... 112
TOP OBJECT FILE................................................................................................................ 113
WHICH OBJECTS WERE COMPILED?..................................................................................... 115
Quick Review: Ex 6....................................................................................................... 116
OBJECTS VS. COGS ............................................................................................................. 117
EXERCISE 7: OUTPUT.SPIN MORE ENHANCEMENTS............................................................ 117
Quick Review: Ex 7....................................................................................................... 123
EXERCISE 8: BLINKER2.SPIN MANY OBJECTS, MANY COGS ................................................ 124
OBJECT INFO WINDOW ........................................................................................................ 128
OBJECT LIFETIME ................................................................................................................ 129
Quick Review: Ex 8....................................................................................................... 130
EXERCISE 9: CLOCK SETTINGS............................................................................................. 131
EXERCISE 10: CLOCK-RELATED TIMING................................................................................ 133
Table of Contents
Propeller Manual v1.0 Page 7
Quick Review: Ex 9 & 10.............................................................................................. 137
EXERCISE 11: LIBRARY OBJECTS......................................................................................... 138
Work and Library Folders............................................................................................. 141
EXERCISE 12: WHOLE AND REAL NUMBERS ......................................................................... 143
Pseudo-Real Numbers ................................................................................................. 143
Floating-Point Numbers................................................................................................ 144
Context-Sensitive Compile Information........................................................................ 147
Quick Review: Ex 11 & 12............................................................................................ 148
CHAPTER 4 : SPIN LANGUAGE REFERENCE.................................................................. 149
STRUCTURE OF PROPELLER OBJECTS ................................................................................. 150
CATEGORICAL LISTING OF PROPELLER SPIN LANGUAGE ....................................................... 152
Block Designators......................................................................................................... 152
Configuration ................................................................................................................ 152
Cog Control .................................................................................................................. 153
Process Control ............................................................................................................ 153
Flow Control ................................................................................................................. 153
Memory......................................................................................................................... 154
Directives...................................................................................................................... 155
Registers ...................................................................................................................... 155
Constants ..................................................................................................................... 156
Variable ........................................................................................................................ 156
Unary Operators........................................................................................................... 156
Binary Operators .......................................................................................................... 157
Syntax Symbols............................................................................................................ 158
SPIN LANGUAGE ELEMENTS................................................................................................. 159
Symbol Rules ............................................................................................................... 159
Value Representations ................................................................................................. 159
Syntax Definitions......................................................................................................... 160
ABORT................................................................................................................................. 161
BYTE................................................................................................................................... 165
BYTEFILL............................................................................................................................ 169
BYTEMOVE............................................................................................................................ 170
CASE................................................................................................................................... 171
CHIPVER ............................................................................................................................. 174
CLKFREQ ............................................................................................................................. 175
_CLKFREQ............................................................................................................................ 177
CLKMODE ............................................................................................................................. 179
_CLKMODE............................................................................................................................ 180
CLKSET ............................................................................................................................... 183
CNT..................................................................................................................................... 184
COGID................................................................................................................................. 186
COGINIT ............................................................................................................................. 187
Table of Contents
Page 8 Propeller Manual v1.0
COGNEW................................................................................................................................ 189
COGSTOP.............................................................................................................................. 193
CON ..................................................................................................................................... 194
CONSTANT ............................................................................................................................ 200
CONSTANTS (PRE-DEFINED) ................................................................................................. 202
CTRA, CTRB......................................................................................................................... 204
DAT ..................................................................................................................................... 208
DIRA, DIRB......................................................................................................................... 212
FILE ................................................................................................................................... 215
FLOAT.................................................................................................................................. 216
_FREE.................................................................................................................................. 218
FRQA, FRQB......................................................................................................................... 219
IF....................................................................................................................................... 220
IFNOT.................................................................................................................................. 225
INA, INB ............................................................................................................................ 226
LOCKCLR.............................................................................................................................. 228
LOCKNEW.............................................................................................................................. 230
LOCKRET.............................................................................................................................. 233
LOCKSET.............................................................................................................................. 234
LONG ................................................................................................................................... 236
LONGFILL ............................................................................................................................ 240
LONGMOVE ............................................................................................................................ 241
LOOKDOWN, LOOKDOWNZ......................................................................................................... 242
LOOKUP, LOOKUPZ................................................................................................................ 244
NEXT ................................................................................................................................... 246
OBJ ..................................................................................................................................... 247
OPERATORS........................................................................................................................ 249
OUTA, OUTB......................................................................................................................... 280
PAR ..................................................................................................................................... 283
PHSA, PHSB......................................................................................................................... 285
PRI ..................................................................................................................................... 286
PUB ..................................................................................................................................... 287
QUIT ................................................................................................................................... 291
REBOOT................................................................................................................................ 292
REPEAT................................................................................................................................ 293
RESULT................................................................................................................................ 299
RETURN................................................................................................................................ 301
ROUND.................................................................................................................................. 303
SPR ..................................................................................................................................... 305
_STACK................................................................................................................................ 307
STRCOMP.............................................................................................................................. 308
STRING................................................................................................................................ 310
STRSIZE.............................................................................................................................. 311
Table of Contents
Propeller Manual v1.0 Page 9
SYMBOLS............................................................................................................................ 312
TRUNC................................................................................................................................. 314
VAR..................................................................................................................................... 315
VCFG................................................................................................................................... 317
VSCL................................................................................................................................... 320
WAITCNT ............................................................................................................................. 322
WAITPEQ ............................................................................................................................. 326
WAITPNE ............................................................................................................................. 328
WAITVID ............................................................................................................................. 329
WORD................................................................................................................................... 331
WORDFILL............................................................................................................................ 335
WORDMOVE............................................................................................................................ 336
_XINFREQ............................................................................................................................ 337
CHAPTER 5 : ASSEMBLY LANGUAGE REFERENCE....................................................... 339
THE STRUCTURE OF PROPELLER ASSEMBLY ........................................................................ 339
CATEGORICAL LISTING OF PROPELLER ASSEMBLY LANGUAGE............................................... 341
Directives...................................................................................................................... 341
Configuration ................................................................................................................ 341
Cog Control .................................................................................................................. 341
Process Control ............................................................................................................ 341
Conditions..................................................................................................................... 341
Flow Control ................................................................................................................. 343
Effects........................................................................................................................... 343
Main Memory Access ................................................................................................... 343
Common Operations .................................................................................................... 343
Registers ...................................................................................................................... 345
Constants ..................................................................................................................... 346
Unary Operators........................................................................................................... 346
Binary Operators .......................................................................................................... 347
ASSEMBLY LANGUAGE ELEMENTS........................................................................................ 348
Syntax Definitions......................................................................................................... 348
Propeller Assembly Instruction Master Table............................................................... 349
ABS..................................................................................................................................... 353
ABSNEG ............................................................................................................................... 354
ADD..................................................................................................................................... 354
ADDABS ............................................................................................................................... 355
ADDS................................................................................................................................... 356
ADDSX................................................................................................................................. 356
ADDX................................................................................................................................... 357
AND..................................................................................................................................... 358
ANDN................................................................................................................................... 359
CALL................................................................................................................................... 360
Table of Contents
Page 10 Propeller Manual v1.0
CLKSET................................................................................................................................ 361
CMP ..................................................................................................................................... 362
CMPS ................................................................................................................................... 362
CMPSUB................................................................................................................................ 363
CMPSX.................................................................................................................................. 364
CMPX ................................................................................................................................... 364
COGID.................................................................................................................................. 365
COGINIT.............................................................................................................................. 366
COGSTOP.............................................................................................................................. 367
CONDITIONS ( IF_X ) ............................................................................................................ 368
DJNZ ................................................................................................................................... 370
EFFECTS............................................................................................................................. 371
FIT ..................................................................................................................................... 372
HUBOP.................................................................................................................................. 373
JMP ..................................................................................................................................... 374
JMPRET................................................................................................................................ 374
LOCKCLR.............................................................................................................................. 375
LOCKNEW.............................................................................................................................. 376
LOCKRET.............................................................................................................................. 376
LOCKSET.............................................................................................................................. 377
MAX ..................................................................................................................................... 378
MAXS ................................................................................................................................... 378
MIN ..................................................................................................................................... 379
MINS ................................................................................................................................... 380
MOV ..................................................................................................................................... 380
MOVD ................................................................................................................................... 381
MOVI ................................................................................................................................... 382
MOVS ................................................................................................................................... 382
MUXC ................................................................................................................................... 383
MUXNC.................................................................................................................................. 384
MUXNZ.................................................................................................................................. 384
MUXZ ................................................................................................................................... 385
NEG ..................................................................................................................................... 386
NEGC ................................................................................................................................... 386
NEGNC.................................................................................................................................. 387
NEGNZ.................................................................................................................................. 388
NEGZ ................................................................................................................................... 389
NOP ..................................................................................................................................... 389
OPERATORS........................................................................................................................ 390
OR....................................................................................................................................... 392
ORG ..................................................................................................................................... 392
RCL ..................................................................................................................................... 393
RCR ..................................................................................................................................... 394
Table of Contents
Propeller Manual v1.0 Page 11
RDBYTE ............................................................................................................................... 394
RDLONG ............................................................................................................................... 395
RDWORD ............................................................................................................................... 396
REGISTERS......................................................................................................................... 397
RES..................................................................................................................................... 398
RET..................................................................................................................................... 399
REV..................................................................................................................................... 399
ROL..................................................................................................................................... 400
ROR..................................................................................................................................... 400
SAR..................................................................................................................................... 401
SHL..................................................................................................................................... 402
SHR..................................................................................................................................... 402
SUB..................................................................................................................................... 403
SUBABS ............................................................................................................................... 404
SUBS................................................................................................................................... 404
SUBSX................................................................................................................................. 405
SUBX................................................................................................................................... 406
SUMC................................................................................................................................... 406
SUMNC................................................................................................................................. 407
SUMNZ................................................................................................................................. 408
SUMZ................................................................................................................................... 408
TEST................................................................................................................................... 409
TJNZ................................................................................................................................... 410
TJZ..................................................................................................................................... 410
WAITCNT ............................................................................................................................. 411
WAITPEQ ............................................................................................................................. 412
WAITPNE ............................................................................................................................. 413
WAITVID ............................................................................................................................. 414
WRBYTE ............................................................................................................................... 414
WRLONG ............................................................................................................................... 415
WRWORD ............................................................................................................................... 416
XOR..................................................................................................................................... 417
APPENDIX A: RESERVED WORD LIST.............................................................................. 419
APPENDIX B: ACCESSING MATH FUNCTION TABLES ................................................... 420
INDEX ................................................................................................................................... 425
Preface
Page 12 Propeller Manual v1.0
Preface
Thank you for purchasing a Propeller chip. You will be spinning your own programs in no
time!
Propeller chips are incredibly capable multiprocessor microcontrollers; the much-anticipated
result of over eight years of the intense efforts of Chip Gracey and the entire Parallax
Engineering Team.
This book is intended to be a complete reference guide to Propeller chips and their
programming languages, Spin and Propeller Assembly. Have fun!
Despite our best efforts, there are bound to be questions unanswered by this manual alone.
Check out our Propeller chip discussion forum (accessible from www.parallax.com via the
Support Discussion Forums menu) this is a group especially for Propeller users where
you can post your questions or review discussions that may have already answered yours.
1: Introducing the Propeller Chip
Propeller Manual v1.0 Page 13
Chapter 1: Introducing the Propeller Chip
This chapter describes the Propeller chip hardware. To fully understand and use the Propeller
effectively, its important to first understand its hardware architecture. This chapter presents
the details of the hardware such as package types, package sizes, pin descriptions, and
functions.
Concept
The Propeller chip is designed to provide high-speed processing for embedded systems while
maintaining low current consumption and a small physical footprint. In addition to being
fast, the Propeller provides flexibility and power through its eight processors, called cogs,
that can perform simultaneous independent or cooperative tasks, all while maintaining a
relatively simple architecture that is easy to learn and utilize.
The resulting design of the Propeller frees application developers from common complexities
of embedded systems programming. For example:
The memory map is flat. There is no need for paging schemes with blocks of code,
data or variables. This is a big time-saver during application development.
Asynchronous events are easier to handle than they are with devices that use
interrupts. The Propeller has no need for interrupts; just assign some cogs to
individual, high-bandwidth tasks and keep other cogs free and unencumbered. The
result is a more responsive application that is easier to maintain.
The Propeller Assembly language features conditional execution and optional result
writing for each individual instruction. This makes critical, multi-decision blocks of
code more consistently timed; event handlers are less prone to jitter and developers
spend less time padding, or squeezing, cycles here and there.
Introducing the Propeller Chip
Page 14 Propeller Manual v1.0
Package Types
The Propeller chip is available in the package types shown here.
P8X32A-Q44
44-pin LQFP
P8X32A-D40 40-pin DIP
P8X32A-M44
44-pin QFN
1: Introducing the Propeller Chip
Propeller Manual v1.0 Page 15
Pin Descriptions
Table 1-1: Pin Descriptions
Pin Name Direction Description
P0 P31 I/O
General purpose I/O Port A. Can source/sink 30 mA each at 3.3 VDC. Do
not exceed 100 mA source/sink total across any group of I/O pins at once.
Logic threshold is VDD; 1.65 VDC @ 3.3 VDC.
The pins shown below have a special purpose upon power-up/reset but are
general purpose I/O afterwards.
P28 - I2C SCL connection to optional, external EEPROM.
P29 - I2C SDA connection to optional, external EEPROM.
P30 - Serial Tx to host.
P31 - Serial Rx from host.
VDD --- 3.3 volt power (2.7 3.3 VDC).
VSS --- Ground.
BOEn I
Brown Out Enable (active low). Must be connected to either VDD or VSS.
If low, RESn becomes a weak output (delivering VDD through 5 K) for
monitoring purposes but can still be driven low to cause reset. If high,
RESn is CMOS input with Schmitt Trigger.
RESn I/O
Reset (active low). When low, resets the Propeller chip: all cogs disabled
and I/O pins floating. Propeller restarts 50 ms after RESn transitions from
low to high.
XI I
Crystal Input. Can be connected to output of crystal/oscillator pack (with
XO left disconnected), or to one leg of crystal (with XO connected to other
leg of crystal or resonator) depending on CLK Register settings. No
external resistors or capacitors are required.
XO O
Crystal Output. Provides feedback for an external crystal, or may be left
disconnected depending on CLK Register settings. No external resistors
or capacitors are required.
The Propeller (P8X32A) has 32 I/O pins (Port A, pins P0 through P31). Four of these I/O
pins, P28-P31 have a special purpose upon power-up/reset. At power-up/reset, pins P30 and
P31 communicate with a host for programming and P28 and P29 interface to an external 32
KB EEPROM (24LC256).
Introducing the Propeller Chip
Page 16 Propeller Manual v1.0
Specifications
Table 1-2: Specifications
Model P8X32A
Power Requirements 3.3 volts DC
External Clock Speed DC to 80 MHz (4 MHz to 8 MHz with Clock PLL running)
System Clock Speed DC to 80 MHz
Internal RC Oscillator
12 MHz or 20 kHz (approximate; may range from 8 MHz 20 MHz,
or 13 kHz 33 kHz, respectively)
Main RAM/ROM 64 K bytes; 32 KB RAM + 32 KB ROM
Cog RAM 512 x 32 bits each
RAM/ROM Organization Long (32-bit), Word (16-bit), or Byte (8-bit) addressable
I/O pins 32 CMOS signals with VDD/2 input threshold.
Current Source/Sink per I/O 30 mA
Current Source/Sink per 8 pins 100 mA
Current Draw @ 3.3 vdc, 70 F 500 A per MIPS (MIPS = Freq in MHz / 4 * Number of Active Cogs)
1: Introducing the Propeller Chip
Propeller Manual v1.0 Page 17
Hardware Connections
Figure 1-1 shows an example wiring diagram that provides host and EEPROM access to the
Propeller chip. In this example the host access is achieved through the Propeller Clip device
(a USB to TTL serial converter).
Figure 1-1: Example wiring diagram that allows for programming the Propeller chip and
an external 32 Kbyte EEPROM, and running the Propeller with an external crystal.
Introducing the Propeller Chip
Page 18 Propeller Manual v1.0
Boot Up Procedure
Upon power-up (+ 100 ms), RESn low-to-high, or software reset:
1. The Propeller chip starts its internal clock in slow mode ( 20 KHz), delays for 50 ms
(reset delay), switches the internal clock to fast mode ( 12 MHz), and then loads and
runs the built-in Boot Loader program in the first processor (Cog 0).
2. The Boot Loader performs one or more of the following tasks, in order:
a. Detects communication from a host, such as a PC, on pins P30 and P31. If
communication from a host is detected, the Boot Loader converses with the
host to identify the Propeller chip and possibly download a program into
Main RAM and optionally into an external 32 KB EEPROM.
b. If no host communication was detected, the Boot Loader looks for an
external 32 KB EEPROM (24LC256) on pins P28 and P29. If an EEPROM
is detected, the entire 32 KB data image is loaded into the Propeller chips
Main RAM.
c. If no EEPROM was detected, the boot loader stops, Cog 0 is terminated, the
Propeller chip goes into shutdown mode, and all I/O pins set to inputs.
3. If either step 2a or 2b was successful in loading a program into the Main RAM, and a
suspend command was not given by the host, then Cog 0 is reloaded with the built-in
Spin Interpreter and the user code is run from Main RAM.
Run-Time Procedure
A Propeller Application is a user program compiled into its binary form and downloaded to
the Propeller chips RAM and, possibly, external EEPROM. The application consists of code
written in the Propeller chips Spin language (high-level code) with optional Propeller
Assembly language components (low-level code). Code written in the Spin language is
interpreted during run time by a cog running the Spin Interpreter while code written in
Propeller Assembly is run in its pure form directly by a cog. Every Propeller Application
consists of at least a little Spin code and may actually be written entirely in Spin or with
various amounts of Spin and assembly. The Propeller chips Spin Interpreter is started in
Step 3 of the Boot Up Procedure, above, to get the application running.
Once the boot-up procedure is complete and an application is running in Cog 0, all further
activity is defined by the application itself. The application has complete control over things
like the internal clock speed, I/O pin usage, configuration registers, and when, what and how
many cogs are running at any given time. All of this is variable at run time, as controlled by
1: Introducing the Propeller Chip
Propeller Manual v1.0 Page 19
the application, including the internal clock speed. See Chapter 3: Propeller Programming
Tutorial.
Shutdown Procedure
When the Propeller goes into shutdown mode, the internal clock is stopped causing all cogs
to halt and all I/O pins are set to input direction (high impedance). Shutdown mode is
triggered by one of the three following events:
1) VDD falling below the brown-out threshold (2.7 vdc), when the brown-out circuit is
enabled,
2) the RESn pin going low, or
3) the application requesting a reboot (see the REBOOT command, page 292).
Shutdown mode is discontinued when the voltage level rises above the brown-out threshold
and the RESn pin is high.
Introducing the Propeller Chip
Page 20 Propeller Manual v1.0
Block Diagram
Figure 1-2: Propeller Chip Block Diagram
1: Introducing the Propeller Chip
Propeller Manual v1.0 Page 21
Cog and Hub interaction is critical to the Propeller chip. The Hub controls which cog can
access mutually-exclusive resources, such as Main RAM/ROM, configuration registers, etc.
The Hub gives exclusive access to every cog one at a time in a round robin fashion,
regardless of how many cogs are running, in order to keep timing deterministic.
Introducing the Propeller Chip
Page 22 Propeller Manual v1.0
Shared Resources
There are two types of shared resources in the Propeller: 1) common, and 2) mutually-
exclusive. Common resources can be accessed at any time by any number of cogs.
Mutually-exclusive resources can also be accessed by any number of cogs, but only by one
cog at a time. The common resources are the I/O pins and the System Counter. All other
shared resources are mutually-exclusive by nature and access to them is controlled by the
Hub. See the Hub section on page 24.
System Clock
The System Clock (shown as CLOCK in Figure 1-2) is the central clock source for nearly
every component of the Propeller chip. The System Clocks signal comes from one of three
possible sources: 1) the Internal RC Oscillator, 2) the Clock Phase-Locked Loop (PLL), or
3) the Crystal Oscillator (an internal circuit that is fed by an external crystal or
crystal/oscillator pack). The source is determined by the CLK registers settings, which is
selectable at compile time or at run time. The only components that dont use the System
Clock directly are the Hub and Bus; they divide the System Clock by two (2).
Cogs (processors)
The Propeller contains eight (8) processors, called cogs, numbered 0 to 7. Each cog contains
the same components (see Figure 1-2): a Processor block, local 2 KB RAM configured as 512
longs (512 x 32 bits), two I/O Assistants with PLLs, a Video Generator, I/O Output Register,
I/O Direction Register, and other registers not shown in the diagram. See Table 1-3 for a
complete list of cog registers. Each cog is designed exactly the same and can run tasks
independently from the others.
All eight cogs are driven from the same clock source, the System Clock, so they each
maintain the same time reference and all active cogs execute instructions simultaneously.
See System Clock, above. They also all have access to the same shared resources, like I/O
pins, Main RAM, and the System Counter. See Shared Resources, above.
Cogs can be started and stopped at run time and can be programmed to perform tasks
simultaneously, either independently or with coordination from other cogs through Main
RAM. Regardless of the nature of their use, the Propeller application designer has full
control over how and when each cog is employed; there is no compiler-driven or operating
system-driven splitting of tasks between multiple cogs. This method empowers the developer
to deliver absolutely deterministic timing, power consumption, and response to the embedded
application.
1: Introducing the Propeller Chip
Propeller Manual v1.0 Page 23
Each cog has its own RAM, called Cog RAM, which contains 512 registers of 32 bits each.
The Cog RAM is all general purpose RAM except for the last 16 registers, which are special
purpose registers, as described in Table 1-3. The Cog RAM is used for executable code, data,
variables, and the last 16 locations serve as interfaces to the System Counter, I/O pins, and
local cog peripherals.
When a cog is booted up, locations 0 ($000) through 495 ($1EF) are loaded sequentially from
Main RAM / ROM and its special purpose locations, 496 ($1F0) through 511 ($1FF) are
cleared to zero. After loading, the cog begins executing instructions, starting at location 0 of
Cog RAM. It will continue to execute code until it is stopped or rebooted by either itself or
another cog, or a reset occurs.
Table 1-3: Cog RAM Special Purpose Registers
Cog RAM Map Address Name Type Description
$1F0 PAR Read-Only
1
Boot Parameter
$1F1 CNT Read-Only
1
System Counter
$1F2 INA Read-Only
1
Input States for P31 - P0
$1F3 INB Read-Only
1
Input States for P63- P32
2
$1F4 OUTA Read/Write Output States for P31 - P0
$1F5 OUTB Read/Write Output States for P63 P32
2
$1F6 DIRA Read/Write Direction States for P31 - P0
$1F7 DIRB Read/Write Direction States for P63 - P32
2
$1F8 CTRA Read/Write Counter A Control
$1F9 CTRB Read/Write Counter B Control
$1FA FRQA Read/Write Counter A Frequency
$1FB FRQB Read/Write Counter B Frequency
$1FC PHSA Read/Write Counter A Phase:
$1FD PHSB Read/Write Counter B Phase
$1FE VCFG Read/Write Video Configuration
$1FF VSCL Read/Write Video Scale
Note 1: Only accessible as a Source Register (i.e. MOV DEST, SOURCE).
Note 2: Reserved for future use.
Introducing the Propeller Chip
Page 24 Propeller Manual v1.0
Each Special Purpose Register may be accessed via:
1) its physical register address,
2) its predefined name, or
3) a register array variable with an index of 0 to 15.
The following are examples in Propeller Assembly:
MOV $1F4, #$FF 'Set OUTA 7:0 high
MOV OUTA, #$FF 'Same as above
The following are examples in Spin:
SPR[$4] := $FF 'Set OUTA 7:0 high
OUTA := $FF 'Same as above
Hub
To maintain system integrity, mutually-exclusive resources must not be accessed by more
than one cog at a time. The Hub maintains this integrity by controlling access to mutually-
exclusive resources, giving each cog a turn to access them in a round robin fashion from
Cog 0 through Cog 7 and back to Cog 0 again. The Hub, and the bus it controls, runs at half
the System Clock rate. This means that the Hub gives a cog access to mutually-exclusive
resources once every 16 System Clock cycles. Hub instructions, the Propeller Assembly
instructions that access mutually-exclusive resources, require 7 cycles to execute but they
first need to be synchronized to the start of the Hub Access Window. It takes up to 15 cycles
(16 minus 1, if we just missed it) to synchronize to the Hub Access Window plus 7 cycles to
execute the hub instruction, so hub instructions take from 7 to 22 cycles to complete.
Figure 1-3 and Figure 1-4 show examples where Cog 0 has a hub instruction to execute.
Figure 1-3 shows the best-case scenario; the hub instruction was ready right at the start of that
cogs access window. The hub instruction executes immediately (7 cycles) leaving an
additional 9 cycles for other instructions before the next Hub Access Window arrives.
1: Introducing the Propeller Chip
Propeller Manual v1.0 Page 25
Figure 1-3: Cog-Hub Interaction Best Case Scenario
Figure 1-4 shows the worst-case scenario; the hub instruction was ready on the cycle right
after the start of Cog 0s access window; it just barely missed it. The cog waits until the next
Hub Access Window (15 cycles later) then the hub instruction executes (7 cycles) for a total
of 22 cycles for that hub instruction. Again, there are 9 additional cycles after the hub
instruction for other instructions to execute before the next Hub Access Window arrives. To
get the most efficiency out of Propeller Assembly routines that have to frequently access
mutually-exclusive resources, it can be beneficial to interleave non-hub instructions with hub
instructions to lessen the number of cycles waiting for the next Hub Access Window. Since
most Propeller Assembly instructions take 4 clock cycles, two such instructions can be
executed in between otherwise contiguous hub instructions.
Figure 1-4: Cog-Hub Interaction Worst Case Scenario
Keep in mind that a particular cogs hub instructions do not, in any way, interfere with other
cogs instructions because of the Hub mechanism. Cog 1, for example, may start a hub
instruction during System Clock cycle 2, in both of these examples, possibly overlapping its
execution with that of Cog 0 without any ill effects. Meanwhile, all other cogs can continue
executing non-hub instructions, or awaiting their individual hub access windows regardless of
what the others are doing.
Introducing the Propeller Chip
Page 26 Propeller Manual v1.0
I/O Pins
The Propeller has 32 I/O pins, 28 of which are entirely general purpose. Four I/O pins (28 -
31) have a special purpose at Boot Up and are available for general purpose use afterwards;
see the Boot Up Procedure section on page 18. After boot up, any I/O pins can be used by
any cogs at any time since I/O pins are one of the common resources. It is up to the
application developer to ensure that no two cogs try to use the same I/O pin for different
purposes during run-time.
Each cog has its own 32-bit I/O Direction Register and 32-bit I/O Output Register. The state
of each cogs Direction Register is ORd with that of the previous cogs Direction Registers.
Similarly, each cogs output states is ORd with that of the previous cogs output states. Note
that each cogs output states are made up of the ORd states of its internal I/O hardware and
that is all ANDd with its Direction Registers states. The result is that each I/O pins
direction and output state is the wired-OR of the entire cog collective. No electrical
contention between cogs is possible, yet they can all still access the I/O pins simultaneously!
The result of this I/O pin wiring configuration can easily be described in the following simple
rules:
A. A pin is an input only if no active cog sets it to an output.
B. A pin outputs low only if all active cogs that set it to output also set it to low.
C. A pin outputs high if any active cog sets it to an output and also sets it high.
Table 1-4 demonstrates a few possible combinations of the collective cogs influence on a
particular I/O pin, P12 in this example. For simplification, these examples assume that bit 12
of each cogs I/O hardware, other than its I/O Output Register, is cleared to zero (0).
1: Introducing the Propeller Chip
Propeller Manual v1.0 Page 27
Table 1-4: I/O Sharing Examples
Bit 12 of Cogs I/O
Direction Register
Bit 12 of Cogs I/O
Output Register
Cog ID 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
State of I/O Pin
P12
Rule
Followed
Example 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Input A
Example 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Output Low B
Example 3 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 Output High C
Example 4 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 Output Low B
Example 5 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 Output High C
Example 6 1 1 1 1 1 1 1 1 0 1 0 1 0 0 0 0 Output High C
Example 7 1 1 1 1 1 1 1 1 0 0 0 1 0 0 0 0 Output High C
Example 8 1 1 1 0 1 1 1 1 0 0 0 1 0 0 0 0 Output Low B
Note: For the I/O Direction Register, a 1 in a bit location sets the corresponding I/O pin to the
output direction while a 0 sets it to an input direction.
Any cog that is shut down has its Direction Register and output states cleared to zero,
effectively removing it from influencing the final state of the I/O pins that the remaining
active cogs are controlling.
Each cog also has its own 32-bit Input Register. This input register is really a pseudo-
register; every time it is read, the actual states of the I/O pins are read, regardless of their
input or output direction.
System Counter
The System Counter is a global, read-only, 32-bit counter that increments once every System
Clock cycle. Cogs can read the System Counter (via their CNT register, page 184) to perform
timing calculations and can use the WAITCNT command (page 322) to create effective delays
within their processes. The System Counter is a common resource. Every cog can read it
simultaneously. The System Counter is not cleared upon startup since its practical use is for
differential timing. If a cog needs to keep track of time from a specific, fixed moment in
time, it simply needs to read and save the initial counter value at that moment in time, and
compare all of the later counter values against that initial value.
Introducing the Propeller Chip
Page 28 Propeller Manual v1.0
CLK Register
The CLK register is the System Clock configuration control; it determines the source of and
the characteristics for the System Clock. More precisely, the CLK register configures the RC
Oscillator, Clock PLL, Crystal Oscillator, and Clock Selector circuits. (See Figure 1-2:
Propeller Chip Block Diagram on page 20.) It is configured at compile time by the _CLKMODE
declaration and is writable at run time through the CLKSET command. Whenever the CLK
register is written, a global delay of 75 s occurs as the clock source transitions.
Whenever this register is changed, a copy of the value written should be placed in the Clock
Mode value location (which is BYTE[4] in Main RAM) and the resulting master clock
frequency should be written to the Clock Frequency value location (which is LONG[0] in
Main RAM) so that objects which reference this data will have current information for their
timing calculations. (See CLKMODE, page 179, and CLKFREQ, page 175.) When possible, it is
recommended to use the CLKSET command (page 183), since it automatically updates all the
above-mentioned locations with the proper information.
Table 1-5: CLK Register Structure
Bit 7 6 5 4 3 2 1 0
Name RESET PLLENA OSCENA OSCM1 OSCM0 CLKSEL2 CLKSEL1 CLKSEL0
Table 1-6: RESET (Bit 7)
Bit Effect
0 Always write 0 here unless you intend to reset the chip.
1
Same as a hardware reset reboots the chip. The Spin command REBOOT writes a
1 to the RESET bit.
1: Introducing the Propeller Chip
Propeller Manual v1.0 Page 29
Table 1-7: PLLENA (Bit 6)
Bit Effect
0
Disables the PLL circuit. The RCFAST and RCSLOW settings of the _CLKMODE
declaration configure PLLENA this way.
1
Enables the PLL circuit. Each of the PLLxx settings of the _CLKMODE declaration
configures PLLENA this way at compile time. The Clock PLL internally multiplies the
XIN pin frequency by 16. OSCENA must also be 1 to propagate the XIN signal to the
Clock PLL. The Clock PLL's internal frequency must be kept within 64 MHz to 128 MHz
this translates to an XIN frequency range of 4 MHz to 8 MHz. Allow 100 s for the
Clock PLL to stabilize before switching to one of its outputs via the CLKSELx bits.
Once the Crystal Oscillator and Clock PLL circuits are enabled and stabilized, you can
switch freely among all clock sources by changing the CLKSELx bits.
Table 1-8: OSCENA (Bit 5)
Bit Effect
0
Disables the Crystal Oscillator circuit. The RCFAST and RCSLOW settings of the
_CLKMODE declaration configure OSCENA this way.
1
Enables the Crystal Oscillator circuit so that a clock signal can be input to XIN, or so
that XIN and XOUT can function together as a feedback oscillator. The XINPUT and
XTALx settings of the _CLKMODE declaration configure OSCENA this way. The
OSCMx bits select the operating mode of the Crystal Oscillator circuit. Note that no
external resistors or capacitors are required for crystals and resonators. Allow a crystal
or resonator 10 ms to stabilize before switching to a Crystal Oscillator or Clock PLL
output via the CLKSELx bits. When enabling the Crystal Oscillator circuit, the Clock
PLL may be enabled at the same time so that they can share the stabilization period.
Table 1-9: OSCMx (Bits 4:3)
OSCMx
1 0
_CLKMODE
Setting
XOUT
Resistance
XIN/XOUT
Capacitance
Frequency Range
0 0 XINPUT Infinite 6 pF (pad only) DC to 128 MHz Input
0 1 XTAL1 2000 36 pF 4 to 16 MHz Crystal/Resonator
1 0 XTAL2 1000 26 pF 8 to 32 MHz Crystal/Resonator
1 1 XTAL3 500 16 pF 20 to 60 MHz Crystal/Resonator
Introducing the Propeller Chip
Page 30 Propeller Manual v1.0
Table 1-10: CLKSELx (Bits 2:0)
CLKSELx
2 1 0
_CLKMODE
Setting
Master
Clock
Source Notes
0 0 0 RCFAST ~12 MHz Internal
No external parts.
May range from 8 MHz to 20 MHz.
0 0 1 RCSLOW ~20 kHz Internal
Very low power.
May range from 13 kHz to 33 kHz.
0 1 0 XINPUT XIN OSC OSCENA must be '1'.
0 1 1 XTALx and PLL1x XIN x 1 OSC+PLL OSCENA and PLLENA must be '1'.
1 0 0 XTALx and PLL2x XIN x 2 OSC+PLL OSCENA and PLLENA must be '1'.
1 0 1 XTALx and PLL4x XIN x 4 OSC+PLL OSCENA and PLLENA must be '1'.
1 1 0 XTALx and PLL8x XIN x 8 OSC+PLL OSCENA and PLLENA must be '1'.
1 1 1 XTALx and PLL16x XIN x 16 OSC+PLL OSCENA and PLLENA must be '1'.
Locks
There are eight lock bits (also known as semaphores) available to facilitate exclusive access
to user-defined resources among multiple cogs. If a block of memory is to be used by two or
more cogs at once and that block consists of more than one long (four bytes), the cogs will
each have to perform multiple reads and writes to retrieve or update that memory block. This
leads to the likely possibility of read/write contention on that memory block where one cog
may be writing while another is reading, resulting in misreads and/or miswrites.
The locks are global bits accessed through the Hub via the Hub Instructions: LOCKNEW,
LOCKRET, LOCKSET, and LOCKCLR. Because locks are accessed only through the Hub, only one
cog at a time can affect them, making this an effective control mechanism. The Hub
maintains an inventory of which locks are in use and their current states, and cogs can check
out, return, set, and clear locks as needed during run time. See LOCKNEW, 230; LOCKRET, 233;
LOCKSET, 234; and LOCKCLR, 228 for more information.
Main Memory
The Main Memory is a block of 64 K bytes (16 K longs) that is accessible by all cogs as a
mutually-exclusive resource through the Hub. It consists of 32 KB of RAM and 32 KB of
1: Introducing the Propeller Chip
Propeller Manual v1.0 Page 31
ROM. The 32 KB of Main RAM is general purpose and is the destination of a Propeller
Application either downloaded from a host or uploaded from the external 32 KB EEPROM.
The 32 KB of Main ROM contains all the code and data resources vital to the Propeller chips
function: character definitions, log, anti-log and sine tables, and the Boot Loader and Spin
Interpreter. The Main Memory organization is shown in Figure 1-5.
Figure 1-5: Main
Memory Map
Main RAM
The first half of Main Memory is all RAM. This space is used for your program, data,
variables and stack(s); otherwise known as your Propeller Application.
When a program is loaded into the chip, either from a host or from an external EEPROM, this
entire memory space is written. The first 16 locations, $0000 $000F, hold initialization data
used by the Boot Loader and Interpreter. Your programs executable code and data will
begin at $0010 and extend for some number of longs. The area after your executable code,
extending to $7FFF, is used as variable and stack space.
There are two values stored in the initialization area that might be of interest to your program:
a long at $0000 contains the initial master clock frequency, in Hertz, and a byte following it
at $0004 contains the initial value written into the CLK register. These two values can be
read/written using their physical addresses (LONG[$0] and BYTE[$4]) and can be read by using
their predefined names (CLKFREQ and CLKMODE). If you change the CLK register without using
the CLOCKSET command, you will also need to update these two locations so that objects which
reference them will have current information.
Introducing the Propeller Chip
Page 32 Propeller Manual v1.0
Main ROM
The second half of Main Memory is all ROM. This space is used for character definitions,
math functions, and the Boot Loader and Spin Interpreter.
Character Definitions
The first half of ROM is dedicated to a set of 256 character definitions. Each character
definition is 16 pixels wide by 32 pixels tall. These character definitions can be used for
video displays, graphical LCD's, printing, etc. The character set is based on a North
American / Western European layout (Basic Latin and Latin-1 Supplement), with many
specialized characters inserted. The special characters are connecting waveform and
schematic building-blocks, Greek symbols commonly used in electronics, and several arrows
and bullets.
Figure 1-6: Propeller Font Characters
The character definitions are numbered 0 to 255 from left-to-right, top-to-bottom in Figure
1-6, above. In ROM, they are arranged with each pair of adjacent even-odd characters
merged together to form 32 longs. The first character pair is located in bytes $8000-$807F.
The second pair occupies bytes $8080-$80FF, and so on, until the last pair fills $BF80-
$BFFF. The Propeller Tool includes an interactive character chart (Help View Character
Chart) that has a ROM Bitmap view which shows where and how each character resides in
ROM.
1: Introducing the Propeller Chip
Propeller Manual v1.0 Page 33
The character pairs are merged row-by-row such that each character's 16 horizontal pixels are
spaced apart and interleaved with their neighbors' so that the even character takes bits 0, 2, 4,
...30, and the odd character takes bits 1, 3, 5, ...31. The leftmost pixels are in the lowest bits,
while the rightmost pixels are in the highest bits, as shown in Figure 1-7. This forms a long (4
bytes) for each row of pixels in the character pair. 32 such longs, building from the
characters top row down to the bottom, make up the complete merged-pair definition. The
definitions are encoded in this manner so that a cogs video hardware can handle the merged
longs directly, using color selection to display either the even or the odd character. It also has
the advantage of allowing run-time character pairs (see next paragraph) that are four-color
characters used to draw beveled buttons, lines and focus indicators.
Figure 1-7: Propeller Character Interleaving
Some character codes have inescapable meanings, such as 9 for Tab, 10 for Line Feed, and 13
for Carriage Return. These character codes invoke actions and do not equate to static
character definitions. For this reason, their character definitions have been used for special
four-color characters. These four-color characters are used for drawing 3-D box edges at run
time and are implemented as 16 x 16 pixel cells, as opposed to the normal 16 x 32 pixel cells.
They occupy even-odd character pairs 0-1, 8-9, 10-11, and 12-13. Figure 1-8 shows an
example of a button with 3D beveled edges made from some of these characters.
Figure 1-8: Button
with 3-D Beveled
Edges
The Propeller Tool includes, and uses, the Parallax True Type
Explorer.
The Recent Folders field (above the Folder List) provides a drop-down list of special folders
as well as the most recent folders youve loaded files from. Selecting a folder from the
Recent Folders field causes the Folder List to immediately navigate to that folder. In
addition, if you select a folder in the Folder List which exists in the Recent Folders list, the
Recent Folder field will automatically update itself to display that item.
The first items in the Recent Folders list are Propeller Library and Propeller Library
Demos. These are automatically included to point to the folders where the Propeller library
files exist and where the demos for the library files exist. Those files are included by the
Propeller Tool installer.
If you select a folder that is not in the Recent Folders list, the Recent Folder field will be
blank. The button to the left of the Recent Folders field toggles the function of both the
Recent Folders and Folder List between: 1) showing every drive and folder, and 2) showing
only drives and folders recently used. Setting the mode to show recent folders only is a
convenient way to quickly navigate to commonly used Propeller Project folders among a
large set of unrelated folders on a particular drive or network.
Pane 3: File List and Filter Field
Pane three contains two components: 1) the File List, and 2) the Filter field. The File List
displays all the files contained in the folder selected from the Folder List which match the
filter criteria of the Filter field. The File List can be used in a similar fashion as the right
pane of Windows Explorer.
Using the Propeller Tool
Page 40 Propeller Manual v1.0
The Filter field (below the File List) provides a drop-down list of file extensions, called
filters, to display in the File List. Typically it will be set to show Spin files only (those with
.spin file extensions) but can also be set to show text files or all files. If you navigate to a
folder and dont see the files you expect to see, make sure that the current filter in the Filter
field is set appropriately.
Files in the Files List can be opened into the editor by: 1) double-clicking them, 2) selecting
and dragging them into the Editor pane (pane four), or 3) right-clicking them and selecting
Open from the shortcut menu.
Pane 4: Editor Pane
Pane four is the Editor pane. The Editor pane provides a view of the Spin source code files
youve opened and is the area where you can review, edit, or otherwise manipulate, all the
source code objects for your project. Each file (source code object) you open is organized
within the Editor pane as an individual edit tab named after the file it contains. The currently
active edit tab is highlighted differently than the rest. You can have as many files open at
once as you wish, limited only by memory.
Clicking on an edit tab brings its edit page into view. You can switch between open files by:
1) pressing Alt+CrsrLeft or Alt+CrsrRight, or 2) pressing Ctrl+Tab or Ctrl+Shift+Tab. If you
let the mouse pointer hover over an edit tab long enough it will display a hint message with
the full path and filename of the file it represents. The source code in the edit page is
automatically syntax highlighted, both in foreground and background colors, to help
distinguish block types, element types, comments vs. executable code, etc.
Figure 2-4: Hover the mouse over an edit tab to see
the full path and file name that tab contains.
2: Using the Propeller Tool
Propeller Manual v1.0 Page 41
Each edit page can display source code in one of four views:
1) Full Source
2) Condensed
3) Summary
4) Documentation.
The view mode can be seen or changed, individually for each edit tab, by:
1) selecting the respective radio button with the mouse,
2) pressing Alt+Up or Alt+Down,
3) pressing Alt+<letter>, where <letter> is the underlined hot key of the desired view, or
4) pressing Alt and moving the mouse wheel up or down.
Note that the Documentation view can not be entered if the object can not be fully compiled
at that moment. See the View Modes, Bookmarks and Line Numbers section beginning on
page 61 for more information about view modes.
Since a project can consist of many objects, developing a project can be awkward unless you
can see both the object youre working on and the object youre interfacing to at the same
time. The Editor pane helps here by allowing its edit tabs to be dragged and dropped to
different locations. For example, once multiple objects are open, you can use the left mouse
button to select and drag the edit tab of an object down towards the bottom half of the Editor
pane and simply drop it there. The display changes to show you a new edit tab region where
you just dropped that edit tab. You can continue to drag and drop edit tabs to this new region
if you wish. These steps are illustrated in Figure 2-5.
Using the Propeller Tool
Page 42 Propeller Manual v1.0
Figure 2-5: Viewing and Arranging Multiple Objects
Step 1: To see more than one objects
source code simultaneously, left-click
and drag an edit tab to a lower region
of the Editor Pane.
Step 2: Release the button to drop the
edit tab. The edit tab and its contents
now appear in the new region.
Step 3: Repeat steps 1 and 2 as
necessary for other edit tabs and
resize both regions using the
horizontal splitter between them.
2: Using the Propeller Tool
Propeller Manual v1.0 Page 43
The vertical size of these two regions can be changed by dragging the horizontal splitter bar
separating them. Of course, the objects youre interfacing to can be viewed in whatever
mode is convenient at the moment (Full Source, Condensed, Summary, or Documentation)
while the object youre developing remains in the Full Source view (the only editable view).
The Editor pane even allows its edit tabs to be dragged and dropped completely outside of the
Propeller Tool. When this is done, the new edit tabs occupy a new window that can be
manipulated independently of the Propeller Tool application window. This is particularly
useful for development on computers with more than one monitor; edit tabs can be dragged
from the application in one monitor and dropped onto the desktop of a second monitor.
Figure 2-6: Arranging Objects
Step 1: If desktop space allows, you
can even drag edit tabs outside the
application itself; left-click and drag an
edit tab to a region outside the
Propeller Tool.
Step 2: Release the button to drop the
edit tab; it will drop into a form of its
own that can be moved and sized
independent of the Propeller Tool. You
can drag and drop more edit tabs into
this new form also.
Using the Propeller Tool
Page 44 Propeller Manual v1.0
The Status Bar at the bottom of the Propeller Tool, is separated into six panels, each
displaying useful information at various stages of the development process.
Panel one of the Status Bar always displays the row and column position of the editors caret
in the currently active edit tab.
Figure 2-7: Status Bar
Panel two displays the modified status of the current edit tab: 1) blank, meaning not modified,
2) modified, or 3) read-only.
Panel three shows the current edit mode: 1) Insert (default), 2) Align, or 3) Overwrite. The
edit mode can be changed by pressing the Insert key. See the Edit Modes section beginning
on page 65 for more information about how the different edit modes work.
Panel four shows the compiled status of the current edit tab: 1) blank, meaning uncompiled,
or 2) compiled. This panel indicates whether or not the source code it represents is still in the
form it was in when it was last compiled. If the code has not been changed in any way since
the last compile operation, this panel will say Compiled.
Panel five displays context sensitive information about the current edit tabs source code if
that code has not been changed since the last compile operation. Move the edit pages caret
to CON or DAT block symbols or anywhere within PUB/PRI blocks to see information pertaining
to that region.
Panel six displays temporary messages about the most recent operation. This is the area of
the Status Bar where the error message, if any, from the last compile operation is displayed
until another message overwrites it. This area also indicates successful compilations, font
size changes and other status.
The entire Status Bar displays hints describing the function of each menu item on the menu
bar as well as various other items when you let the mouse pointer hover over those items.
2: Using the Propeller Tool
Propeller Manual v1.0 Page 45
Menu Items
File Menu
New Create a new edit tab with a blank page. Any existing edit
tabs are unaffected.
Open Open a file in a new edit tab with the Open file dialog.
Open From Open a file in a new edit tab from a recently accessed folder
using the Open file dialog.
Save Save current edit tabs contents to disk using the existing file
name, if applicable.
Save As Save current edit tabs contents to disk with a new file name
using the Save As dialog.
Save To Save current edit tabs contents to disk in a recently accessed
folder using the Save As dialog.
Save All Save all unsaved edit tabs contents to disk using their
existing names, if applicable.
Close Close current edit tab (will prompt if file is unsaved).
Close All Close all edit tabs (will prompt for any files unsaved).
Select Top Object File Select the top object file of current project. This setting is
used for all of the Compile Top operations and remains
until changed.
Archive
Project Collect all objects and data files for the project shown in
Object View and store them in a compressed (.zip) file along
with a readme file containing archive and structure
information. The compressed file is named after the
projects top file with Archive plus the date/time stamp
appended and is stored in the top files work directory.
Project + Propeller Tool... Perform the same task as above but add the entire Propeller
Tool executable to the compressed file.
Using the Propeller Tool
Page 46 Propeller Manual v1.0
Hide/Show Explorer Hide or show the Integrated Explorer panels (left side of the
application window).
Print Preview View a sample of the output before printing.
Print Print the current edit tabs contents.
<recent files> The menu area between the Print and Exit items displays
the most recently accessed files, up to ten. Selecting one of
these items opens that file. Point the mouse at a recent file
menu item to see the full path and file name in the status bar.
Exit Close the Propeller Tool.
Edit Menu
Undo Undo the last edit action on the current edit page. Each edit
page retains its own undo history buffer until closed.
Multiple undo actions are allowed, limited only by memory.
Redo Redo the last undone action on the current edit page. Each
edit page retains its own redo history buffer until closed.
Multiple redo actions are allowed, limited only by memory.
Cut Delete the selected text from the current edit page and copy
it to the Windows clipboard.
Copy Copy the selected text from the current edit page to the
Windows clipboard.
Paste Paste text from the Windows clipboard to the current edit
page at the current caret position.
Select All Select all text in the current edit page.
Find / Replace Open the Find/Replace dialog; see Find/Replace Dialog on
page 49 for details.
Find Next Find the next occurrence of the last search string entered into
the Find/Replace dialog.
Replace Replace the current selection with the string entered into the
Replace field of the Find/Replace dialog.
Go To Bookmark Go to bookmark 1, 2, 3 (visible only when bookmarks are
shown).
2: Using the Propeller Tool
Propeller Manual v1.0 Page 47
Text Bigger Increase the font size in every edit page.
Text Smaller Decrease the font size in every edit page.
Preferences Open the Preferences window. Users can customize many
settings within the Propeller Tool using this feature.
Run Menu
Compile Current
View Info Compile source code in current edit tab and, if successful,
display Object Info form with the results. The Object Info
form displays many details about the resulting object
including object structure, code size, variable space, free
space and redundancy optimizations.
Update Status Compile source code in current edit tab and, if successful,
update the status info on the Status Bar for every object in
the project.
Load RAM Compile source code in current edit tab and, if successful,
download the resulting application into Propeller chips
RAM and run it.
Load EEPROM Compile source code in current edit tab and, if successful,
download the resulting application into Propeller chips
EEPROM (and RAM) and run it.
Compile Top
View Info Same as Compile Current View Info except compilation
is started from the file designated as the Top Object File.
Update Status Same as Compile Current Update Status except
compilation is started from the file designated as the Top
Object File.
Load RAM Same as Compile Current Load RAM + Run except
compilation is started from the file designated as the Top
Object File.
Load EEPROM Same as Compile Current Load EEPROM + Run except
the compilation is started from the file designated as the
Top Object File.
Using the Propeller Tool
Page 48 Propeller Manual v1.0
Identify Hardware Scan available ports for the Propeller chip and, if found,
display the port it is connected to and the hardware version
number.
Help Menu
Propeller Tool Display on-line help about the Propeller Tool.
Spin Language Display on-line help about the Spin language.
Assembly Language Display on-line help about the Propeller Assembly language.
Example Projects Display on-line help containing example Propeller Projects.
View Character Chart Display the interactive Parallax Character Chart. This
character chart shows the Parallax fonts character set in
three possible views: Standard Order, ROM Bitmap and
Symbolic Order. Standard Order is the standard ANSI order.
ROM Bitmap demonstrates how the character data is
organized in the Propeller chips ROM. Symbolic Order
lists the characters in a categorical order (i.e.: alpha
characters, numerics, punctuation, schematic symbols, etc).
See Character Chart on page 58.
View Parallax Website Open up the Parallax website using the computers default
web browser.
E-mail Parallax Support Open up the computers default email software and start a
new message to Parallax support.
About Displays the About window with details about the Propeller
Tool.
2: Using the Propeller Tool
Propeller Manual v1.0 Page 49
Find/Replace Dialog
The Find/Replace dialog is used to find and/or replace text in the current edit page.
Figure 2-8: The Find/Replace Dialog
Find:
The Find: field is where to enter the string you wish to search for. If a word or phrase was
selected in the current edit page when the Find/Replace dialog was opened, that word or
phrase will automatically be entered in the Find: field. The Find: field remembers the last ten
unique items entered into it. To select a previous entry, click the Find: fields down arrow
and choose it from the drop-down list.
Replace:
The Replace: field is where to enter the string you wish to replace the found string with. The
Replace: field remembers the last ten unique items entered into it. To select a previous entry,
click the Replace: fields down arrow and choose it from the drop-down list.
Match
The Match group controls how the string in the Find: field is matched to text in the edit page.
The Match options are: 1) Whole Words, 2) Case, and 3) With Wildcards.
Using the Propeller Tool
Page 50 Propeller Manual v1.0
Whole Words
Select the Whole Words checkbox if you want the string in the Find: field to match only
characters of entire words rather than both characters of entire words and characters within
larger words.
Case
Select the Case checkbox if you want the string in the Find: field to match only text of the
same case; a case-sensitive search.
With Wildcards
Select the With Wildcards checkbox if you want the search to be performed using regular
expression wildcards from the string in the Find: field.
The Origin, Scope and Direction groups all work together to dictate the start, range and
direction the search process should use.
Origin
The Origin group controls where the search begins from; from the Top or from the Cursor.
Selecting Top starts the search from the top of the file (or from the top of the selection if
Selection is set in the Scope group). Selecting Cursor starts the search from the current
cursor (caret) position in the file. Note: The Top option changes to Bottom if the
Direction group is set to Backward.
Scope
The Scope group controls the range of the search: the Entire File or just the current Selection.
This is a convenient way to perform a find, or a find and replace, within only a limited region
of the file. The Scope group is set to Entire File by default and is disabled unless a selection
is made prior to opening the Find/Replace dialog. The Scope group is set to Selection
automatically if a selection of at least one entire line is made prior to opening the
Find/Replace dialog.
Direction
The Direction group controls the direction of the search; in the Forward direction (towards
the bottom of the file) or the Backward direction (towards the top of the file). If set to
Backward, the Origin groups first option changes from Top to Bottom, meaning the
origin is from the bottom of the file or selection.
2: Using the Propeller Tool
Propeller Manual v1.0 Page 51
Find Button
The Find button starts the search process based on all the settings in the Find/Replace dialog.
If text in the edit page matches the criteria, it is selected and moved into view, and then the
Find button changes to a Find Next button. Additional clicks on the Find Next button result
in the next matching text being selected and shown. You can also use the F3 key, with or
without the Find/Replace dialog open, to perform more Find Next searches.
Replace Button
The Replace button is enabled if a string was entered in the Replace: field and a matching
string was found (via Find button or F3). Clicking Replace, or pressing F4 with or without
the Find/Replace dialog open, causes the currently matched string in the file to be replaced
with the string in the Replace: field. After a replace, the Find Next button, or F3 key, needs
to be used before Replace becomes available again. Holding the Control (Ctrl) key down
changes the Replace button to Replace/Find and clicking it, or pressing Ctrl+F4 with or
without the Find/Replace dialog open, causes the currently matched string to be replaced and
then another Find Next operation to be performed immediately.
Replace All Button
The Replace All button is enabled if a string was entered in the Replace: field. Clicking on
Replace All causes every matching string in the file to be found and replaced with the string
in the Replace field, the dialog closes, and a results dialog appears indicating the number of
occurrences found and replaced.
Close Button
The Close button closes the Find/Replace dialog.
Using the Propeller Tool
Page 52 Propeller Manual v1.0
Object View
The Object View displays a hierarchical view of the project you most recently compiled
successfully. There are two Object Views in the Propeller Tool: 1) The Object View at the
top of the Integrated Explorer in the main applications window (see Pane 1: Object View
Pane on page 39), and 2) The Object Info View in the upper left of the Object Info form (see
Object Info on page 55). Both of these Object Views function in a similar fashion.
The Object View provides visual feedback on the structure of the most recent successful
compilation as well as information for each object within the compiled project.
Figure 2-9: Example Object View display showing
the structure of the ABC Product compilation
In Figure 2-9 above, the Object View indicates the structure of the ABC Product application.
In this example, the ABC Product object is the top object file (see Objects and
Applications, page 87) and it uses the Numbers, Rotary Encoder and Controller objects.
Additionally, the Controller object uses the TV object.
The object names shown are their actual file names without the extension. The name
includes their file extension only if they are data files (see FILE, page 215) and is shown in
italics as well.
The icons to the left of each object name indicate the folder that the object exists in. This list
shows the four possibilities:
(yellow): Object is within the Work Folder.
(blue) : Object is within the Library Folder.
(striped): Object is in Work Folder but another object with the same name is also
being used from the Library Folder.
(hollow): Object is not in any folder because it has never been saved.
2: Using the Propeller Tool
Propeller Manual v1.0 Page 53
Work Folder
The Work Folder (yellow) is the folder where the top object file exists. Every project has
one, and only one, work folder.
Library Folder
The Library Folder (blue) is where the Propeller Tools library objects exist, such as those
that came with the Propeller Tool software. The Library Folder is always the folder that the
Propeller Tool executable started from, and every object (file with .spin extension) within it is
considered to be a library object.
Striped Folders
Objects with striped icons indicate that an object from the work folder and an object from the
library folder each refer to a sub-object of the same name and that sub object happens to exist
in both the work and library folders. This same-named object may be: 1) an exact copy of the
same object, 2) two versions of the same object, or 3) two completely different objects that
just happen to have the same name. Regardless of the situation, it is recommended that you
resolve this potential problem as soon as possible since it may lead to problems later on, such
as not being able to use the Archive feature.
Hollow Folders
Objects with hollow icons indicate that the object was created in the editor and has never
been saved to any folder on the hard drive. This situation, like the one mentioned above, is
not an immediate problem but can lead to future problems if it is not addressed soon.
Using the mouse to point at and select objects can provide additional information as well.
Clicking on an object within the Object View opens that object into the Editor pane. Left-
clicking opens that object in Full Source view, right-clicking opens it in Documentation view
and double-clicking opens it, and all its sub-objects, in Full Source view. If the object was
already open, the Editor pane simply makes the related edit tab active and switches to the
appropriate view; Full Source for a left-click or double-click, or Documentation for a right-
click.
Using the Propeller Tool
Page 54 Propeller Manual v1.0
Hovering the mouse over an object in the Object View displays a hint with additional
information for that object. Figure 2-10a shows the hint for the ABC Product object. This
hint indicates 1) the ABC Product object is the top object file of the project, 2) it exists in the
work folder, and 3) its path and file name are: C:\Source\ABC Product.spin. From this
information you can also infer that the work folder for this project is:
C:\Source
a.
b.
Figure 2-10: Hover the mouse over an object
to see hints with additional information
Figure 2-10b shows the hint for the Numbers object: 1) its an object file (i.e.: a sub object,
rather than the top object), 2) its in the library folder, and 3) its at the path and file name:
C:\Program Files\Parallax Inc\Propeller\Numbers.spin. From this information you can also
infer that the library folder for this project is:
C:\Program Files\Parallax Inc\Propeller.
Its a good idea to review the hints in the Object View occasionally since they may also
contain additional helpful information, such as warnings about conflicts and optimization
results.
2: Using the Propeller Tool
Propeller Manual v1.0 Page 55
Object Info
The Object Info form displays details about the project you just compiled successfully using
the Compile Current/Top View Info function. At the top is an Info Object View very
similar to that of the Integrated Explorers Object View (see Object View, p. 52). Below the
Info Object View are two panels with summary information.
Figure 2-11: Object Info
Form
This example Object Info
display shows details about
the ABC Product project
compilation.
Using the Propeller Tool
Page 56 Propeller Manual v1.0
Info Object View
The Info Object View works exactly like the Object View (see Object View, p. 52) with a
few exceptions:
Clicking on an object within the Info Object View updates the Object Info display
with information pertaining to that object.
Double-clicking on an object within the Info Object View opens that object in the
Edit pane.
Data files are not selectable in the Info Object View.
RAM Usage Panel
The RAM Usage panel displays statistics about RAM allocation by the object currently
selected in the Info Object View. The horizontal bar gives a summary view of the entire
RAM with its color legend and numerical details below it. For example, Figure 2-11 shows
that the ABC Product object consumes 524 longs (2096 bytes) for program space and 12
longs (48 bytes) for variable space, leaving over 7k longs (over 30k bytes) free.
Clock Panel
The clock panel, under the RAM Usage panel, displays the clock/oscillator settings of the
object currently selected in the Info Object View. For example, Figure 2-11 shows that the
ABC Product object configured the clock for RCFAST, approximately 12 MHz and no XIN
frequency.
Hex View
The Show/Hide Hex button shows or hides the detailed object hex view, as in Figure 2-12 on
the next page. The hex view shows the actual compiled object data, in hexadecimal, that are
loaded into the Propeller chips RAM/EEPROM upon download.
2: Using the Propeller Tool
Propeller Manual v1.0 Page 57
Figure 2-12: Example Object Info Form display with the object Hex View
open showing the hex values of the ABC Product compilation.
The buttons under the hex display allow for downloading and saving of the currently
displayed hex data.
The first two buttons, Load RAM and Load EEPROM, perform the same function as the
similarly named menu items under the Compile Current/Top menu. Its important to note
that they use the current object (the one selected in the Info Object View) as the source to
download. In other words, you can actually select a sub-object from the project and
download just that; a practical procedure only if that object were designed to run completely
on its own.
The last three buttons, Open File, Save Binary File, and Save EEPROM File, either open a
file or save a file to disk. The Open File button opens a previously saved Binary or EEPROM
file into the Object Info window. The save buttons save the hex data from the currently
selected object to a file on disk. Save Binary File saves only the portion actually used by the
object; the program data, but not variable or stack/free space. Save EEPROM File saves the
entire EEPROM image, including variable and stack/free space. Use Save EEPROM File if
you wish to have a file that you can load into an EEPROM programmer for production
purposes.
Using the Propeller Tool
Page 58 Propeller Manual v1.0
Character Chart
The Character Chart window is available from the Help View Character Chart menu
item. It shows the entire character set for the Parallax Font that is used by the Propeller Tool
and is also built into the ROM of the Propeller chip. There are three views in the Character
Chart: 1) Standard Order, 2) ROM Bitmap, and 3) Symbolic Order.
In each of the three views, the mouse, left mouse button, cursor keys and enter button can be
used to highlight and select a character. If clicked (or enter pressed), the highlighted
character will be entered into the current edit page at the current cursor location. As a new
character is highlighted, the title bar and info bar of the window updates to show the name,
size and address information for that character. Moving the mouse wheel up or down
changes the font size displayed in this window.
Standard Order
Standard Order, shown in Figure 2-13, displays the characters in the order that follows that of
the ANSI set typically used by modern day computers.
Figure 2-13: Parallax Font Character Chart, Standard Order
2: Using the Propeller Tool
Propeller Manual v1.0 Page 59
The Vertical Resistor character (near the lower right of the display) is selected in this
example. The information at the bottom of the window shows the font size, in points, and the
characters location in the character set in decimal, hexadecimal, and Unicode. Note: The
Unicode value is the address of the character in the True Type