Page 94 - Build Your Own Quadcopter_ Power Up Your Designs with the Parallax Elev-8
P. 94
Chapter 4: Prog ramming the P arallax Propeller Chip 73
short delay once power is applied to the BOE, since it takes 1.5 seconds to copy the 32-kB
ROM image into the 32-kB RAM memory.
Just in case you were wondering, user programs cannot be loaded into the Prop chip’s
internal 32-kB ROM memory. Doing so would overwrite and destroy the Prop’s firmware,
essentially eliminating the Spin interpreter and critical data storage tables—in effect,
“bricking” your Prop chip.
Prop Software
Until recently, the Prop has been programmed by using the Spin language and the Propeller
Assembly Language (PASM). Now, the C Language has been added to the available
programming tools that support the Prop. I will focus initially on Spin, since it is the primary
language to use when programming the Prop. I will discuss PASM and C in Chapter 5.
Spin Language
The Spin Language is one that I refer to as an object-oriented (OO) hybrid language, meaning
that it uses many of the features of a full blown OO language, such as Java or C++, while
directly dealing with the constraints and limitations inherent in a real-time programming
environment. For instance, the Spin language does not support some basic OO functionality,
such as creating and destroying dynamic objects. Spin’s underlying reliance on the Prop
chip’s functionality precludes supporting this basic OO feature. This does not mean that
Spin is not a highly useful OO tool; it just means that the normal programming approach
must be altered to reflect the Prop’s architecture. The Spin language designers recognized
that not all OO programming paradigms could be realistically implemented in a real-time,
parallel-processing environment. The Spin compiler is an extremely well-designed software
development tool that enables you to create true parallel-processing programs that also
efficiently execute in a real-time environment. There are other parallel-development tools
available, but none that I know of that are so user friendly and make it so easy to develop
practical program solutions.
It would be naïve of me and a disservice to you to attempt to thoroughly cover OO
programming fundamentals in this chapter. I would urge you to learn some basic imperative
programming concepts, and at least, go through an introduction to OO programming
principles. It will be difficult for you to fully comprehend how the example Prop programs
function without some programming background. If you lack a good foundation, you will
find it difficult to modify the examples to suit your own needs. The authors of the Parallax
Propeller User's Manual also make the same assumption that the reader should have some
OO background. With this disclaimer stated, I recommend that everyone download and
read the latest Propeller User's Manual. Readers who have some OO development experience
will still need to read the important information within the manual. Writing Prop software
is really quite different from developing normal OO software because you have to consider
the presence of parallel-processing cogs and a real-time operating environment. Given these
issues, I will include some detailed explanations in the following discussions in order to
clarify the Spin programming statements.
Propeller Spin Tool
The Propeller Spin Tool (PST) is a free tool provided by Parallax, which allows you to create,
load, and execute software on any Prop-based development board or functioning prototype
Prop circuit. As mentioned earlier in the chapter, I used the Prop BOE for software