Quickstart

If you need help with any of this I can be found on IRC at ##tech40+ (irc.freenode). I’m in Australia, and usually asleep midnight till dawn EST (Australia).

What is Mecrisp-Stellaris ?

  • Released under Version 3 of the GPL, Mecrisp-Stellaris Forth by Matthias Koch is Free Software. See: https://sourceforge.net/projects/mecrisp/files/ to download your version
  • Mecrisp-Stellaris Forth runs on M0, M3, M4 and M7 ARM Cortex M chips. This is a big family of microcontrollers with a common processor architecture and very different peripheral capabilities.
  • The Mecrisp-Stellaris Distribution tarball comes with ready to run binaries for all supported chips, you don’t need to compile anything.
  • Despite the name, not only Stellaris chips are supported.
  • Mecrisp-Stellaris Forth fits into 19 kb of flash and runs with at least 1 kb of ram.
  • If you wish Mecrisp-Stellaris Forth ran on your favourite chip, just get in contact with Matthias, and maybe there will be another port soon.

What is Forth ?

If you are familiar with Forth already, then bypass this note and go straight to “Quick Start Here” below.

Note

  • Forth was invented by Charles Moore
  • Forth is a program that once flashed into your MCU allows you to immediately write and test programs, read Registers, toggle GPIO pins, read the A-D and much, much more. No compiler is needed as it is built into the program, which is flashed onto the MCU. All you need is a serial terminal to talk to the MCU in Forth.
  • Mecrisp-Stellaris Forth can run on a single $0.60 STM32F051 MCU with zero external components, but you may need a filter capacitor depending on your wiring layout.

This is a STM32F051-QFN MCU I hand soldered onto 0.1” pitch fibreglass matrix board and flashed with Mecrisp-Stellaris. It has only one filter cap and works perfectly. Those large shiny wires are 0.5m wirewrap wire, exactly the width of the QFN pads.

_images/stm32051qfn-forth.jpg

Quick Start Here

This describes the basic steps to quickly install flash Mecrisp-Stellaris onto a STM32F “Discovery Board” so you can try it out ASAP. In this example I’ll use a STM32F0 Discovery board, but the general process is the same for other models.
  1. Download the latest Mecrisp-Stellaris tarball: http://mecrisp.sourceforge.net/

  2. Extract the binary for your MCU, in my case it’s: mecrisp-stellaris-stm32f051.bin

  3. Install Stlink
    • FreeBsd and OpenBsd: devel/stlink
    • Linux: You may need to compile it with Linux Debian as they don’t seem to have a stlink.deb. See https://github.com/texane/stlink
  4. Connect your Discovery board to your PC using a usb cable, a led for the board power should light.

Note: Root or sudo will be required for the erase and write steps below

  1. Erase the flash on the board by running
st-flash erase

It’s advised to press the reset button on the board before the next step.

  1. Now flash the board with the Mecrisp-Stellaris binary, remember to use the binary for your MCU
st-flash write mecrisp-stellaris-stm32f051.bin 0x08000000
  1. Connect a 3.3v-USB dongle to your PC and make sure it works in a serial terminal emulator such as “Picocom”, “Minicom”, “Cutecom” etc by connecting the 3.3v TX and RX wires and observing that keys are echoed to the screen when hit. See this table for which pins to use for your board/chip. Connection config is: 115200 baud, 1 stop bit, no parity bit, and no handshaking, no xon/off. Below is a picocom example but your /dev/cuaU0 device will probably be different to mine.
picocom -b 115200 /dev/cuaU0 –imap lfcrlf,crcrlf –omap delbs,crlf
  1. Connect the TX, RX and GND wires from the 3.3v-USB dongle to your Discovery board, which pins are used depends on the board/MCU so check the pin numbers in the “Connecting a Serial Terminal” Section in this documentation.
  2. When all is working, pressing the reset button on your Discovery Board will result in a similar message being sent to your screen.
Mecrisp-Stellaris 2.3.6 with M0 core for STM32F051 by Matthias Koch

FINISHED! at this point Mecrisp-Stellaris Forth is running on your Microcomputer.

While Picocom is great for a quick test, I recommend that you use E4thcom as it is specifically made for programming and uploading files to a Forth Micocomputer.

Where to go now ?

Have a look in the Dictionary for all the commands you can use ?

How about running some ‘blinky’ programs on a F0 Discovery Board ?

STM32F051 Discovery Board, about $10

_images/stm32-disco.jpg

Where to go next ?

It’s traditional to build a LED ‘blinky’ as your first embedded program, and we have lots here, check out the Blinky Bazar

How about some working projects ?

You may be wondering, ‘if a chip has a thousand register and register bitfields, how will I ever write all those Memory Mapped words?’ Fortunately you don’t have to if you use svd2forth. So why not check it out ?

Into Object Oriented Programming ? we have some exiting new developments here

Any other tips ?

Sure, have a browse around this site (if you haven’t already):-

I’ve found some bugs, horrible spelling errors, or have some good tips, corrections etc, who do I contact ?