Introduction

The Cheap Microcontroller Problem

When developing Embedded Electronics, testing the peripherals is a important part of the process. For instance when the Micro tells LED 1 to light, does that work, or when switch one is pressed, is it detected ?

Add 100 leds and 50 switches and that’s a lot of testing/development time.

One advantage of C is that a PC can compile a massive C program into a small binary ‘Machine Code’ program enabling the use of small 2KB Flash memory in low cost products, thereby saving money. Unfortunately C is not interactive and requires code to be written for every type of test with some way of returning the results. Whilst it’s easy to see if a LED is working, returning the 16 bit result from a Analog to Digital Converter that may or may not be working properly during the design phase is not as simple.

Forth, such as Mecrisp for the popular MSP430 MCU makes near real time interactive testing very easy, but it requires at least 11KB of Flash, so won’t fit into a 2KB Flash memory.

The Forth Solution

Is a “Tethered Forth”. This allows near real time speed during the development process and yet produces a small compiled binary ‘Machine Code’ program for the cheaper 2KB Flash Microcontrollers in exactly the same way that C does.

The equipment consists of a fast and capable Cortex M Microcontroller, “The Host” with lots of Flash and speed running Mecrisp-Stellaris and talking to a serial terminal for the developer to use.

The Target is a memory limited MSP430 Microcontroller which is Tethered” to the Host with a four wire cable allowing remote control via JTAG.

To the developer, it looks and feels like the Terminal is connected directly to the Target even though it’s the Host doing all the work by cross-compiling Forth Words into the Targets native Machine Code and executing it on the Target in near real time.

When the Forth program is finished, the Host consolidates all the Words, constants and variables etc then compiles them into a single Machine Code program and flashes it to the Target to allow standalone operation without the Tether.

Mecrisp-Across

Mecrisp-Across was designed by Matthias Koch, the author of Mecrisp-Stellaris (and many other applications) who said that “Mecrisp-Across is the most complicated compiler I have ever written”.

Mecrisp Across :

  • Is designed for the very popular Texas Instruments MSP430 MCUs available in DIP packaging, making them easy to hand solder.
  • Runs on the smallest, low cost MSP430 chips some as low as $0.78 USD each in 100x quantities, from Mouser.com. ( MSP430FR2000IPW16R 500 Byte FRAM, 512 Byte SRAM, 1.8 - 3.6V, 16 pin TSSOP )
  • Is a “Tethered Forth” system which allows writing and testing Forth code on a Target too small to host Forth internally.
  • Generates and flashes the project binary image to the Target from the Host via JTAG.
  • Includes a very strong optimising cross compiler running on a TM4C1294 which generates Machine Code for Texas Instruments MSP430 chips such as the MSP430F2013 (14 pin DIP).
  • Compiler is capable of global optimisations, automatic inlining, dead code elimination and register allocation of both data and return stack across control structures.

Note

Mecrisp-Across also supports Linux and Qemu-Static which is not discussed in this documentation as my interest is only a Tethered Forth for near realtime development, not simulation on a PC. If you want to use Qemu-Static, please refer to the Readme.

The Host

The (cross compiling) Host is a Texas Instruments TM4C1294 Tiva Connected Launchpad shown below:

_images/tiva.jpg

The Target

The Target is a Texas Instruments MSP-EXP430G2 Board with a MSP430F2013IN target MCU. The target MCU in the board shown below is a different one, a MSP-EXP430G2. The difference doesn’t matter and the examples should all run the same way.

_images/msp-exp430g2.jpg

Note

The Target doesnt have to be a commercial board like this, it could be a single MSP430 chip, a MSP430 chip hand soldered on some matrix board or even a header (containing a MSP430 mcu and a short shielded JTAG umbilical cable) which plugs into the MSP430 socket on your hand soldered project board.

Ready to Get Started ?

Jump to Installing

Previous topic

Mecrisp-Across Unofficial Documentation

Next topic

Why Mecrisp-Across is AWESOME!