Quantcast
Viewing latest article 11
Browse Latest Browse All 296

F103 + USB = Swiss Army Knife

The USB driver for STM32F103 has been around for months and it’s proving to be very stable and usable. The current Mecrisp release nowincludes it, and there’s an F303 port available.

The original code and inspiration for this driver came from Eckhart Köppen’s early CoreForthimplementation. While changes and a whole lot of head-scratching was needed, his code was proof that implementing a serial port driver in Forth was worth trying, and ulitmately: doable!

Having a Forth implementation interacting via serial USB is a big deal, because of the large variety of very low-cost F103-based boards on eBay. With Forth installed, and some utility code such as from theEmbello project, you end up with a plug-and-play jack-of-all-trades gadget:

  • a 32-bit ARM chip running at 72 MHz
  • an interactive command prompt, ready to tinker
  • lots of drivers pre-loaded
  • a collaborative multi-tasker and easy to use software timers
  • plenty of free flash and RAM to implement fun stuff
  • a snappy serial console, noticeably faster than a 115,200 baud link
  • no toolchain: just plug it in and use Folie or some other terminal emulator

The no toolchain aspect is quite important, as it means that you can take such a board with you, and use it to start trying out physical-computing related stuff wherever you are:

  • connecting over USART, I2C, or SPI with “other devices”
  • reading analog data at up to 1 Msps and 12-bit resolution
  • generating square waves or pulses, or multi-bit patterns

… as well as all the obvious tasks of reading out button states, encoders, driving LEDs, connecting relay-, motor-, or stepper-drivers and … making real things “happen”.

When you need more I/O pins and more interfaces than the TQFP-48 package on the low-end F103 boards provide: there are also 100-pin and 144-pin packages, with considerably more I/O, more h/w interfaces, and more features (like DACs) - search for “STM32F103 board” on eBay.

To use a Blue Pill and others for all sorts of quick / ad-hoc projects requires:

  1. A simple way to upload Mecrisp and additional Forth code onto each new board
  2. Access to easy-to-use documentation for the (over 750!) pre-loaded “words”

Part one is handled by Folie, which can upload a USB firmware image IF you have a BUB III, modified BUB, or SerPlus-enabled board (or else a BMP or ST-Link, with proper software).

For details on how to upload a complete USB-enabled image to one of several common F103 boards with Folie, see thisREADME on GitHub. There is a nasty chicken-and-egg problem involved in creating a suitable BUB- or SerPlus-like interface, but once you have such a thing, turning an F103-based µC board into this Swiss Army Knife will be a piece of cake.

Part two has not yet been covered as well, unfortunately. There’s a newdocumentation area in the Embello repository on GitHub, used to generate this site - but it’s still early days.

The main words in the Mecrisp core are (tersely) documented on the official glossary page.

If you would like to help improve on this, by improving the documentation, or by contributing general-purpose code, or drivers for some USART/I2C/SPI device, please consider submitting a pull request, which is GitHub’s powerful way ofcollaborating on open source projects. With a pull request, your contribution will not only show up among all the others, Git also archives the complete logs of who contributed what and when, i.e. giving full attribution to everyone.

As well as an honourable mention, as a small-but-sincere token of appreciation.


Viewing latest article 11
Browse Latest Browse All 296

Trending Articles