ColorPAL documentation

© Parallax, Inc. • ColorPAL (2009.06.15) Page 6 of 12
Direct Commands
To begin programming the ColorPAL, you will need to be in Direct mode. In this mode, the ColorPAL will
accept any of four different commands. These are:
= (Equal sign): Begin buffering commands.
! (Exclamation point): Begin executing the buffered code.
# (Pound sign): Save the buffered code to an address in EEPROM.
+ (Plus sign): Receive a “network” address.
=
Begin Buffering Commands
!
Execute Buffered Commands
Any programming (i.e. color-related) commands that the ColorPAL executes must first be buffered before
they can be executed. Here is a typical buffer-and-execute sequence that causes the RGB LED to light up
red:
SEROUT sio, baud, ["= R !"]
Note: Any blanks embedded
within a buffered command sequence
(i.e. after the “=” and before a “!” or
“#”) are optional and can be added to enhance program readability. Adding them affects neither the
speed of a program nor the amount of memory it requires. However,
do not embed blanks in a direct
command sequence!
Doing so will cause the ColorPAL’s automatic baud rate detection to fail.
#nn
Save Buffered Program to EEPROM
Saving a program to EEPROM requires an address to be supplied in hexadecimal and ranging from 00 to
3F.
All
numerical arguments passed to the ColorPAL are done so as two-digit hexadecimal constants (00
to FF). To store the “light up red” program to EEPROM location zero (for automatic startup), say, you’d
do this:
SEROUT sio, baud, ["= R #00"]
This, along with the prior example, also illustrates that both the execute (!) and save (#) commands will
immediately exit Buffer mode and enter Direct mode.
IMPORTANT: If the program you save starts automatically (i.e. is stored at location 00) and outputs
data, it will do so at an uncalibrated baud rate, somewhere around 4800 baud. The reason is that the
ColorPAL calibrates its baud rate from commands sent to it in Direct mode. Lacking any such commands
when autostarting, it has to pick a default value. Because the ColorPAL uses an RC oscillator for its
timebase, it’s hard to predict with any degree of accuracy what the actual output baud rate will be.
There are two ways around this. One is to restart the stored program manually by entering Direct mode
and issuing an Execute command. The ColorPAL will pick up the desired baud rate from this.
The other option is to auto-detect the baud rate at which the ColorPAL is transmitting and use it instead.
Here’s a PBASIC program that will do that. It will work with any BASIC Stamp, except the BS2px: