Saturday, August 22, 2015

Adventures in ARM Land - Part 1 - Surveying the Territory


This post is the first of a series of three (or more), intended to introduce the newcomer to the world of 32bit ARM processors, based on my past experiences. Whilst not a tutorial with code examples (these are available elsewhere online) it is hoped that others will be inspired to follow a similar journey.

In this post I introduce some low cost commercially available development boards, and the range of software tools currently available with which to program them.

I also showcase three of my own open source hardware designs, to illustrate that these microcontroller pcbs are not beyond the realm of hobbyist pcb design and construction.

On the Job Tinkering with ARM Chips

In November 2013, I had the opportunity to explore a new range of 32 bit microcontrollers as part of a development to upgrade our product range at work.

Since then, I have been working both professionally and on a hobby basis with the series of ARM Cortex M microcontrollers from ST Microelectronics.

I was initially attracted to this series of devices because of their rich set of peripherals and resources, low cost development boards and that there was a rapidly growing User Community.

Having put a significant amount of time into familiarising myself with this new family of processors, I have found that they are relatively easy to use, and that it is fairly straightforward to move between different members of the family - depending on your application.

There are a very wide range of target boards available - some starting at less than $5 (from China). Additionally, ST Microelectronics produces it's own range of very low cost target boards - to get you quickly started on your application.

Not an Arduino and not a Pi

The STM32Fxxx family of 32bit microcontrollers are available with clock speeds between 72MHz and 216MHz.  This places them at about 4 to 16 times faster than an Arduino based on the 16MHz ATmega328. In addition, their 32bit wordsize, larger flash memory and RAM allows more complex applications to be run.  The STM32F  Cortex M4 has a floating point unit (FPU) capable of executing single cycle multiplication, hardware divide and some DSP instructions.

Whilst faster than the original Arduino (and Due),  they cannot compete in speed with the 1GHz quad core Raspberry Pi 2. However, as they were designed for the embedded microcontroller market, they have several peripherals that the Pi lacks - such as 12bit ADCs and DACs.  Also, as they are unlikely to ever support Linux, it means that your application is not constrained by the operating system, giving you full access to the timing - making them ideal for Real Time Control applications.

Finally, the processor has a  number of power saving modes, and even flat out will only consume between 50 and 100mA.  This makes them ideal for hand held, battery operated applications.  

Maple Mini (Chinese Copy)

A "Maple Mini" - a low cost STM32F103 board from China
The Maple Mini was one of the first hobbyist boards to use the STM32F103 - originally produced by Leaf Labs in Canada. Leaf Labs no longer support this board, but it has been widely copied in China and is available for as little as $5.  The example above is a 40 pin DIL format making it ideal to fit into a prototyping breadboard.  Leaf Labs derived their own version of the Arduino IDE - and now through a community project, their code has now been adopted and updated by Arduino STM32  - allowing you to program these little boards directly from the Arduino language.  Ideal for beginners.

Nucleo Boards

These are produced by ST Microelectronics and offer a very low cost way to get started with ARM and mbed programming.  The upper part of the pcb is a "detachable" ST Link V2 flash programmer - alone worth about £20. The programmer section can be used with a 6 way cable to program other STM32F ARM boards you may have.

The lower part of the pcb has both Arduino footprint connectors - allowing the use of some Arduino shields, but additionally the STM "Morpho" dual row connectors, allowing access to all of the I/O pins.

Nucleo-F103RB - about £8.50 from Farnell CPC

This ability to change between processors has been exploited to it's full potential with the range of ST Nucleo development boards - a small, low cost, "Arduino like" platform, with built in flash programmer, and the means to be programmed using the online mbed compiler.  Each Nucleo board is fitted with a 64pin LQFP microcontroller which being virtually pin identical, allows you to choose which processor best suits your application.

A full list of Nucleo boards is described here - but notably here are the ones I have used

STM32F103   ARM Cortex M3   72MHz  - a good general purpose microcontroller

STM32F303   ARM Cortex M4F   72MHz  - Analogue SoC with 5MSPs ADC, PGA etc

STM32F373   ARM Cortex M4F   72MHz  - 3 x 16bit SD ADCs

STM32F401   ARM Cortex M4F   84MHz  - low power microcontroller

STM32F401   ARM Cortex M4F   100MHz  - low power microcontroller

If you choose to develop code for these using the mbed platform, you can readily switch between target boards to assess which target is best for your application.  For example, whilst all STM32Fxxx microcontrollers have multiple 12bit ADC and DAC channels,  you will find that the STM32F303 has the highest speed ADC (5MSPs) but the STM32F373 offers in addition, 3 independent 16 bit ADCs - which is ideal for 3-phase energy measurements.

If however you are looking for a low power controller perhaps for extended battery operation, the STM32F401 and 411 are described as STM's  "Dynamic Efficiency Line" and use a "Batch Acquisition Mode" BAM - a low power means of acquiring data from sensors, processing the data, then returning to a low power state.

Discovery Boards

Discovery F4 - About £12.50 from Farnell

STM also has a range of feature rich Discovery Boards - with additional hardware included on board to specifically highlight typical user applications. The top quarter of the pcb is the STM32F  ST Link V2 flash programmer.  All of the STM32F407 GPIO pins are broken out into the twin row connectors.

This Discovery F4 board is a powerful board - with a processing throughput approximately 15 times that of an Arduino.  It has 80 GPIO lines and a rich set of peripherals making it idea for motor control and instrumentation systems.

These are available for the following microcontrollers (plus others)

STM32F303   - with on board compass and accelerometer sensors

STM32F407  - with accelerometer, audio sampling and playback

STM32F429  - with colour LCD

STM32F746  - with colour touchscreen LCD, Ethernet + camera, audio, + much, much more

My own ARM journey started with the Discovery F4,  but I have evaluated the others above, for various applications, both at work and for play.

Software Tools

There is an ever increasing number of options available to allow you to program these microcontrollers - so far I have looked at the following:

1.  A fully functioning tool suite from one of the major suppliers - very expensive
2.  A code size limited tool chain - free to use for smaller applications
3.  An online tool chain - for example mbed
4.  Free to use IDE using open source GCC  - Coocox CoIDE
5.  Online Javascript - notably Espruino - offering JS to STM32xxx microcontrollers
6.  Aruino_STM32  - a community based extension to Arduino allowing Arduino IDE coding for STM32F  Cortex and M3 and M4.

Some of these are windows platform only.  Some do not fully support certain microcontrollers - so for example, whilst I generaly use Coocox or mbed,  I had to use a 32K code size limited version of Keil's uVision 5 in order to develop code for the STM32F746  Cortex M7.

Arduino STM32 is an interesting option for hobbyists, because it allows an easy transition from the AVR based Arduino platforms to much more powerful ones based on the STM32F103. Sketches written for the Arduino can be easily ported to ARM M3 and M4 based hardware. It also allows the Arduino community to break free from the limitations of the official Arduino platforms.

Some Hardware Notes

The STM32Fxxx range of microcontrollers are available in a range of package sizes from LQFP-48 upwards. The "leaded quad flat pack" package may be soldered by hand, if sufficient care is taken. This offers the options for enthusiasts to  design their own pcbs - using EagleCAD or KiCAD etc.

Personally, I have designed pcbs to accept 48 pin, 64 pin and 100 pin parts using EagleCAD. Initially these were intended as Breakout Boards - so that I could access all the peripheral pins - without other hardware getting in the way.  Later, these designs generally evolved into more application specific devices.

Three of my existing designs are intended for Open Sourcing:

1. ARMiGo - accepts a 48 pin LQFP, either STM32F103, STM32F303 or STM32F373 and makes its pins available on a 40 pin 0.6" DIL header - intended for breadboard prototyping.

2. Piano Forte  - accepts  a 64 pin LQFP, either STM32F103, STM32F303 or STM32F373 and makes its I/O available in an Arduino pin-out  or as 2.1" wide SIL header format - that can be placed across 2 breadboards.  Can also be plugged into a Raspberry Pi - and used as a PI-HAT compatible Analogue and Digital I/O board to augment the Pi.

3. BoB  - A totally uncluttered breakout board for the 100 pin LQFP STM32F746.  Breaks out the I/O of the STM32F746 into the 2x25 pin dual row headers as used on the Discovery F4. Allows the Cortex M7 to be evaluated as an 2X+ performance upgrade to the Cortex M4.


In the UK, STM32 Discovery and Nucleo boards may be obtained from

Farnell    - business customers
CPC       - hobbyists
RS Components

In the US


No comments: