Spin is the high-level language used to program the Parallax Propeller processor. Propeller is an embedded microprocessor with eight (8) cores. The cores are called “cogs”. The Spin language has commands for assigning code to certain cogs so you can have tasks running truly in parallel. This simplifies tasks that would otherwise be handled by interrupts or a multi-tasking operating system. In fact, interrupts are not even used in Spin.
Advantages to Spin
Spin is in some ways similar to BASIC, but it is structured like C. This makes it easy to learn.
Spin is the easiest way for someone new to embedded microprocessors to handle multiple tasks. You can blindly assign different functions to different cogs without worrying about task latency. The Propeller chip’s cogs are truly running in parallel. It’s not a software abstraction. The developer has control over eight (8) processors, each running at 80MHz.
The development tool is easier than average to get going. It’s less powerful than Code Composer Studio, but it’s more straightforward to get running.
The biggest disadvantage to Spin is efficiency. Driving a single GPIO line high and then low takes about 50 microseconds, which is an astounding 4000 clock cycles. In Propeller Assembly (PASM) it takes 200 nanoseconds, which is 16 clock cycles. Spin makes provisions to insert assembly code easily into a program. The assembly language is about average difficulty as assembly languages go.
If your application is simple enough that you only need one core, Spin is a little harder to use than C. This disadvantage relative to C goes away as soon as you need to multitask, though, because Spin makes it easy to assign a task to a cog.
The Propeller chip does not have a hardware serial controller. All asynchronous serial (UART), SPI, and I2C communication must be bit-banged. Bit-banging ties up a processor, but the Propeller chip has eight (8) processors, so this is not as bad as big-banging on a single-core microprocessor.
Eight cogs sounds like a lot, but many everyday tasks, such as doing big-banged PWM on one pin while monitoring another pin, require more than one cog. On a complicated project, you quickly start running out of cogs.
Although the free development tool is easy to use, it is not an IDE that supports breakpoints. This is not as troublesome as it sounds because it’s easy to have one cog reporting status information through the serial port. There is an advanced development tool called ViewPort that provides typical IDE features like runtime stepping, breakpoints, and memory value display.
Getting Started
The fastest way to get started is with the Propeller Demo board. I has ports for PS/2 keyboard and mouse, RCA video, audio, USB (with FTDI serial chip), and VGA. The RCA video uses four (4) GPIO ports connected to different resistor values to create a 4-bit DAC. The video quality is amazingly good. You wouldn’t suspect such a crude DAC drives the output.
If you need access to all Propellers GPIO, you can use the Propstick, which has a USB port for debugging and breaks out every pin on the Propeller chip to pins that can plug into a standard 100-mi-pitch breadboard.
The Parallax website has a good deal of sample code and great forums with people eager to answer questions.
Writing Spin for the Propeller chip is the fastest way for a beginner to get started doing projects requiring multiple low-latency tasks.