In my case, the scale factor works out to 1.1038. I had
selected RCSLOW mode which has an assumed frequency
of 20 kHz. With the adjustment, the top of my program
DEVICE P8X32A, RCSLOW
The FREQ setting will drive the compiler and in the
end, we’ll have corrected timing for things like PAUSE,
SEROUT, etc. Figure 2 shows the uncorrected output
(without using FREQ) from my test; Figure 3 is after the
FREQ setting has been added.
The next section of the template involves defining
constants. There’s no mystery here with standard numeric
and single character constants.
OnTime CON 250
OffTime CON 750
IsOn CON 1
IsOff CON 0
Asterisk CON “*”
If a program will be using SERIN or SEROUT, then the
baud mode constant is defined like a string.
Baud CON “T9600”
This definition can be used to drive SERIN and SEROUT
in true mode (standard when using the programming port)
at 9600 baud. Mind you, I’m just using this as an example.
PropBASIC compiles to assembly and when running at 80
MHz, we can have very fast baud rates.
Constants are global in a PropBASIC application and
can be used in multiple cogs (i.e., the main program and
any tasks that run).
LED PIN 16 LOW
Declaring I/O pins in PropBASIC is very much like
PBASIC 2. 5 and SX/B, while using the SX/B convention of
allowing the pre-assignment of the pin state immediately
after a reset. The options for a pin are INPUT (default),
OUTPUT (same as LOW), LOW, and HIGH. In my programs that
will communicate with a terminal program, I include these
RX PIN 31 INPUT
TX PIN 30 HIGH
18 March 2010
Note the use of the HIGH option; I do this so that
auto-generated start-up code places the TX pin in the idle
state (output and high) for serial communications through
the Propeller programming port.
LEDs PIN 23..16 LOW
In a pin group definition, the first number is the MSB
pin of the group, the second is the LSB pin of the group.
The order is important as it affects how bits will be
presented at outputs or read when the group is set as
In PropBASIC 1.0, we can only assign a simple value
to an output pin group. That means that this line:
LEDs = %100000
is legal, but ...
LEDS = 1 << position
is not. This is likely to be addressed in a future version. In
the meantime, we can use one of PropBASIC’s temporary
variables like this:
__temp1 = 1 << position
LEDs = __temp
PropBASIC allows us to store variables and variable
arrays in the Hub that can be accessed by any cog. Hub
variables may be defined as bytes, words, or longs, or
arrays of either type.
rxHead HUB Byte = 0
rxTail HUB Byte = 0
rxBuffer HUB Byte(64) = 0
Note that PropBASIC allows us to pre-assign values to
Hub variables. If the pre-assignment option is not used,
the variable (and all elements of an array) will be set to
zero. Though they are variables, what we store in the Hub
cannot be used in expressions like regular variables. There
are two instructions — RDxxxx and WRxxxx — that are used
to read and write Hub variables (the instruction used will
be based on the variable size; you’ll see examples in a
Along with variables, we can store shared data in
the Hub, as well. With 32K of RAM, this allows for very
large tables, and being in the Hub these tables can be
accessed from any cog. Hub data can be declared as
bytes, words, or longs using, respectively, the DATA, WDATA,