Created Sun, 19 Jun 2011 08:40:46 +0000 by rtestardi
Sun, 19 Jun 2011 08:40:46 +0000
Have you ever wished you could examine and manipulate the pins and peripherals of your MCU interactively, while it was live and connected to your embedded circuit, rather than using just "reset and run" debugging? If so, StickOS BASIC may be for you!
With StickOS BASIC, you can log in to your MCU using nothing but a terminal emulator, and then take full control of the MCU from a command-line, just as if you had an In-Circuit Emulator. StickOS can run either in "slave" mode, tethered to and controlled by a host computer as a glorified intelligent I/O port, or it can run in "master" mode, programmed in BASIC, interactively debugged, and even configured to autorun its BASIC program autonomously.
In StickOS BASIC, it is trivial to examine and manipulate I/O pins. I/O pins can be configured for digital input or output, analog input or output, servo output, or frequency output. Once a pin is configured, it can be bound to a BASIC variable, and from then on, examining or manipulating the pin is as simple as examining or manipulating the bound variable.
For example, to configure pin 3 for servo output, bind it to the variable "motor1", and then set it up for a 1ms (1000us) PWM pulse width is as easy as (interactively, at the command-line, or in a program):
> dim motor1 as pin 3 for servo output > let motor1=1000 > _
In StickOS BASIC, it is equally trivial to use timers, UARTs, advanced I2C or SPI peripherals, as well as HD44780-compatible LCDs and simple scanned keypads.
And most importantly, it can all be done interactively -- no more guessing what your MCU is up to! The StickOS debugger supports command-line program interruption, breakpoints, assertions, watchpoints, live variable (and pin) manipulation and examination, execution tracing and single-stepping, sampling profiling, and even edit-and-continue!
When you're ready to move up, you can then port your BASIC program to C using the MPLAB X StickOS Skeleton project, and take advantage of all the same pin/peripheral configuration, flash manipulation, etc., used by StickOS BASIC.
A detailed introduction to StickOS on the chipKIT boards is here: [url]http://www.cpustick.com/chipkit.htm[/url]
An overview of the StickOS BASIC language features is in the Quick Reference guide, here: [url]http://www.cpustick.com/downloads/quickref.v1.82.pdf[/url]
More information and downloads for the chipKIT boards are available here: [url]http://www.cpustick.com/downloads.htm[/url]
For an older video introduction, start with part 1 here and then follow it to parts 2 and 3: [url]http://www.youtube.com/watch?v=nSgha8qjB3E[/url]
-- Rich (email@example.com)
Sun, 19 Jun 2011 14:19:04 +0000
While I am not a big fan of basic on any machine, this looks pretty cool.
I do wish you would NOT recommend people to cut the reset line. This will make the board much harder to use in its normal configuration in the future.
Is the source code to this available?
Sun, 19 Jun 2011 21:56:15 +0000
Oh, I cut the reset line and installed a jumper there so I could put it back whenever I wanted -- the board seemed totally designed to do this. Basically, there is an unpopulated jumper (jp1 on the Uno32 and jp5 on the Max32) with a trace between the two pins on the underside of the board. You can cut the trace and install a 2-pin male header on the top of the board, and then you can put a jumper on the male header any time you want it to restore the original behavior -- so I don't think there is any real risk (other than the normal risk associated with using an exacto knife! :-)).
Most of the source code is available in the "skeleton project" at the bottom of the "downloads" page ( http://www.cpustick.com/downloads.htm ) so folks can recompile StickOS for other (in-family) MCUs, change serial ports, add custom BASIC commands and statements, etc. The source code includes all the code that does initialization, pin and peripheral configuration, flash memory manipulation, USB, i2c, SPI, CDC/ACM, vt100 line editing, etc. The only code that is in library form is the core of the BASIC language itself, where we do, say, for-next loops, variables, merging of RAM and flash memory for bytecode (to preserve flash lifetime), etc. -- that part can't be changed (except you can add custom BASIC commands and statements to it, rename pins to match board layouts, for custom hardware, etc.).