Propeller Manual

Table Of Contents
2: Spin Language Reference – CON
Common Constant Declarations (Syntax 1)
The most common forms of constant declarations begin with
CON on a line by itself followed
by one or more declarations.
CON must start in column 1 (the leftmost column) of the line it is
on and we recommend the lines following be indented by at least one space. The expressions
can be combinations of numbers, operators, parentheses, and quoted characters. See
Operators, page 143, for examples of expressions.
Example:
CON
Delay = 500
Baud = 9600
AChar = "A"
—or—
CON
Delay = 500, Baud = 9600, AChar = "A"
Both of these examples create a symbol called Delay that is equal to 500, a symbol called
Baud that is equal to 9600, and a symbol called AChar that is equal to the character “A”. For
the
Delay declaration, for example, we could also have used an algebraic expression, such as:
Delay = 250 * 2
The above statement results in Delay equaling 500, like before, but the expression may make
the code easier to understand if the resulting number were not just an arbitrary value.
The
CON block is also used for specifying global settings, such as system clock settings. The
example below shows how to set the Clock Mode to low-speed crystal, the Clock PLL to 8x,
and specify that the XIN pin frequency is 4 MHz.
CON
_CLKMODE = XTAL1 + PLL8X
_XINFREQ = 4_000_000
See _CLKMODE, page 68, and _XINFREQ, page 236, for detailed descriptions of these settings.
Floating-point values can also be defined as constants. Floating-point values are real
numbers (with fractional components) and are encoded within 32 bits differently than integer
constants. To specify a floating-point constant, you must give a clear indication that the
Propeller Manual v1.1 · Page 85