ST Micro has announced new families of Cortex-M0-based microcontrollers, called STM32F0x2. These will feature Full-speed USB. The first available parts are STM32F072. It looks like a good fit for projects and experiments in many areas. It may be a good fit for folks who want a low-cost move to ARM.
As I’ve come to expect, there isn’t a thru-hole Dual-In-Line (DIL) package (sigh). However, ST have announced packages including a 20 pin TSOP. This is a compact dual-in-line surface mount package. So it would be similar to the FTDI USB chip on the older Arduino boards. I think that is very doable for DIY assembly boards. It’s likely within the Maker-ability of some 13yo doing electronics in Design & Technology. However, the STM32F072 isn’t available in TSOP 20, that will be a future STM32F042. It is available in 48pin LQFP, so I may be able to put it onto a variant of my Orone-mini designs.
The ‘killer’ feature is full-speed USB. USB was previously reserved for the Cortex-M3 and M4 parts. The STM32F072’s USB is significantly better than the existing parts because it doesn’t need a crystal to get the frequency accuracy required by USB. Instead it has a built-in clock. This is one of the great features of FTDI’s (and others) USB interface chips. An internal USB clock saves board space and cost, making a DIY board even cheaper, easier to make, and maybe even smaller. If you look at my Orone-mini designs you can see that the crystal (left and above centre) consume quite a lot of space. That crystal is one of the smallest sizes, and costs close to a low-end STM32F microcontroller (MCU).
The STM32F072 is better from a Makers-perspective than existing STM32F103’s because it has a manufactured-in USB bootloader. This enables a newly-assembled board to have programs uploaded from a PC over USB. We only need a USB cable. Yipee! This would be great for large groups of makers. For example folks in classrooms or public events could make a board, then load test programs without the cost of a specialist USB-to-UART cable or programmer. Some USB-to-UART cables and most programmers cost more than the entire STM32F072 board! The built-in bootloader also supports loading programs over the USART and even I2C.
Let me summarise that lot because it does simplify ‘bootstrapping’ a DIY board. An STM32F072 board will not need a crystal on board. It can be programmed over USB ‘out of the packet’. It will not need:
- bootloader software to be uploaded before it can be used, or
- 6pin programming header, or
- specialist programming device, or
- USB-to-UART cable, or
- extra USB-to-UART chip.
This seems delightfully maker-friendly.
The real joy of STM32F MCU’s are the peripherals. The STM32F072 is pretty well stocked for a low-cost part. I’ve added [notes] comparing Arduino UNO’s ATmega328, but this might be misleading because there aren’t always enough pins on the STM32F072 package to get at everything. For example there are potentially 17 independent PWM pins, but I could only find 16 on a 48pin package.
STM32F072 peripherals [Arduino UNO's ATmega328]
- 16channel 12bit Analogue to Digital Converter (ADC), 1Msps [10bit, 8 channel, 10ksps]
- dual channel Digital to Analogue Converter (DAC) [no]
- 9 timers 
- 16 PWM channels 
- independent SysTick timer for millisecond clock [uses 1 of the 3 timers]
- Battery-backed Real Time Clock & Calendar with alarm & wakeup [no]
- Battery-backed memory (20 bytes) [1KiB EEPROM, slower but bigger]
- two I2C [one]
- two SPI, or I2S [one, no I2S]
- four USARTS [one]
- CAN [no]
- USB [no, Leonardo has one]
- HDMI SEC [no]
- 7 Direct Memory Access (DMA) channels [no]
- 24 channel capacitive touch sensing [library available, uses GPIO]
- two comparators [one]
- two “Watch dog” timers [one]
The STM32F072’s Cortex-M0 CPU is slower than the Cortex-M3 or M4 in other STM32F families. However, Cortex-M0 is still a full 32bit processor, running about 3x faster than Arduino UNO’s 8bit ATmega, so it will be a real improvement for folks requiring more processing ‘oomph’. It can be programmed with the same tool chains as Cortex-M3/M4.
There are several groups of peripherals that get my brain buzzing. I2S supports high-end audio chips. However, the fast ADC and dual DAC enables lots of audio projects, for example guitar effects, or voice processing, with little extra electronics. The capacitive touch sensing system might be enough to make a small, two octave keyboard from a piece of PCB. To be fair, it’d take quite a lot more computer power to ‘auto-tune’ my singing, like ‘real’ singers use. ;-)
I like robotics and motors, so I look for lots of timers and PWM channels. Like most STM32F’s there are several different types of timers. The majority are pretty straightforward, and combine all of the features of ATmega’s timers. Further, a few are designed to directly generate the signals to drive Brushless DC motors (BLDC) and stepper motors. BLDC motors are used in electric model cars, airplanes, boats, as well as disk drives and fans. Stepper motors are often used on robot arms, and autonomous vehicles, as well as 3D printers and 3D scanners, because they can be moved to a precise, reproducible position without the added complexity of feedback from encoders. The timers that are designed for this type of role have complementary outputs to control motor-drive H-bridges, and ‘break’ inputs to stop generating drive signals when a problem is detected.
Many of the other peripherals have useful features too. For example some USARTS support Infrared Data exchange (IrDA), or talking to smart cards.
The Direct Memory Access (DMA) controller can offload work from the Cortex-M0 CPU. For example it could move data from memory into the USB peripheral, or from the USB peripheral into memory, and alert the processor when it’s done.
So the setup might be:
unsigned char buff[size];
volatile unsigned int* USART_Tx = (unsigned int*)(0x40004428);
Then the DMA controller would do this by itself:
for (int i=0; i<size; i++) *USART_Tx = buff[i];
This isn’t a sophisticated as a multi-core processor, or Parallax’s Propeller, but there is quite a lot it can do. It is more complex to program the DAM than use a peripheral directly; so it’s only worth the programming effort when the task is so demanding that the processor needs some help. Where it makes sense, peripherals have mechanisms for working with DMA. For example, DMA can be triggered by the ADC to save samples from different channels, and pump data out via the DAC at the same time, while the processor gets on doing other work. So DMA can move data back and forth between memory and any peripherals like GPIO, SPI, I2S, I2C, CAN, USART, USB, etc.
The STM32F072 is available now on one of ST’s speciality, super-affordable development boards, the STM32F072B-DISCO. ST quote $10.40 for the board with the 128KiB Flash, 16 KiB of SRAM, in a 64pin package. It includes:
- On-board ST-LINK/V2 hardware debugger
- 3-axis digital gyroscope
- One Linear Touch Sensor or four Touch Keys
- Four User LEDs and a User push button
Best of all, it has single rows of pins so it could be used with a breadboard (though it is quite long with 33 pins on each side. I don’t think it has been updated yet, but texane’s Open Source stlink software at github supports program upload and hardware debugging with gdb for previous STM32F parts.
I’m assuming the price is in line with the current Cortex-M0 parts. In the announcement, ST quote a large quantity cost of $1.32 for a 64KiByte, 48pin. So under £2 for smaller quantities, maybe 5 or 10-off, might be plausible.
Summary: This looks like a useful, Maker-friendly low-cost ARM. It has low-cost USB, supported by built-in USB bootloader. There are plenty of useful and interesting peripherals. I like robotics and audio, but it has stuff for many other interests e.g. HDMI, smartcards, touch sensors, etc. The sub £10 Discovery board, with hardware debug, and single-row pin headers should let us start using it quite quickly. Yum.