Spin (programming language)
From Wikipedia, the free encyclopedia
Spin is a multitasking object oriented high level programming language created by Parallax, Inc. for their line of Propeller microcontrollers.
Spin code is written on "the propeller tool". A GUI oriented software development platform which is written for Windows XP. This compiler converts the Spin code into bytecodes that can be loaded, (with the same tool) into the main 32KB RAM, (and optionally into the serial boot FLASH EEPROM) of the Propeller chip. After booting the propeller a bytecode interpreter is copied from the built in ROM into the 2K RAM of the primary COG. And then this COG will start interpreting the bytecodes in the main 32KB RAM.
More than one copy of the bytecode interpreter can run in other COG's, so several Spin code threads can run simultaniously.
Within a the general Spin code program assembler code program(s) can be "inline" inserted. These assembler program(s) will then run on their own COG's.
Contents |
[edit] Syntax
The syntax of Spin can be broken down into blocks. The blocks are as following.
[edit] VAR
Holds global variables
[edit] CON
Holds program constants
[edit] PUB
Holds code for a sub-routine
[edit] OBJ
Contains code for objects
[edit] Keywords
reboot: causes the microcontroller to reboot
waitcnt: wait for an amount of clock cycles
COGINIT: starts a processor on a new task
[edit] sample code
This code sets a pin high (1)
PUB Start
DIRA[0]~~ 'sets pin 0 to input
OUTA[0]~~ 'sets pin 0 high