Goodbye Arduino, Hello STM32

Coming Soon to Doayee

Motivation

Arduino is great. It’s easy to use, understand and the online community can answer just about any question you have. As a beginner it was exactly what I needed to dip my toes in the water, just enough problem solving to keep me interested, and enough excitement to fuel me. Most projects I’ve done to date involved an Arduino somewhere along the line, from a university project to build a capacitance meter, to a score tracking project for Airsoft arenas, and I really can’t sing its praises enough if you want a quick solution to a simple problem.

But now I’ve found myself in a new area: I don’t want a quick solution to a simple problem, I want a reliable solution to a complex problem. And here, Arduino just ain’t gonna cut it.

 

Friendly and functional

The Arduino IDE

The Arduino IDE

There are many good reasons Arduino doesn’t live up to this task, especially when you’re making products for customers, not just for your own satisfaction. One of these reasons is the licensing, which is a major obstacle for anyone wanting to sell their product (and not make the code public), there’s a great post over on Embedded.fm about this. But the main reason, which the embedded article goes into also, is the IDE.

The IDE is a masterful way of getting people interested, it’s clean and friendly, with only a couple of buttons and an intuitive interface. You don’t see a single mention of a linker, or makefiles, and even the libraries are done in as simple a way as possible. It really encourages you to just… code. And once you’ve finished writing it, you click the button and as if by magic your code is now running in your hand. This is great if your program is a couple hundred lines long, and uses a single library, maybe two.

But what if you want to write a program which is a couple thousand lines long? And uses several interfaces at once?

For one: you’d have to find an Arduino capable of running such a program, which the Uno almost certainly isn’t. You’d be pushing the envelope with the Mega. And on top of this, those couple thousand lines are going to end up in a single file (yes I know there is a way of making multiple files in the IDE and using tabs etc… but it isn’t easy, and it doesn’t come with any of the features of a fully fledged IDE – ‘goto declaration’ being one which I quickly found myself reliant on). Thirdly, you’re gonna be using all of the Arduino ‘backend’, which obfuscates a good deal of the complexity away from you. Don’t get me wrong, there is some absolutely stellar programming running behind each sketch, but if you want performance optimisation, this is not the right way to go.

So where do you go?

The STM32F3 Discovery

Well this is where I had a stroke of luck. I started working in Research and Development for a scientific instrumentation company, as part of my degree program, and was handed a project which fit this bill almost to the letter. I was given a desk to work at, a project brief, and one of the boards pictured to the right: an STM32F3 Discovery. I won’t lie, I was completely clueless on how to use it. But I was surprised by how little time it took before I was reliving those milestones I’d conquered back when I first picked up that little blue Arduino, except this time, I could see how it was working. Blinky came and went, and then I was reading from an ADC, and then I was using a DAC, and SPI, and I2C, and suddenly I felt like an embedded developer. For real this time!

I started out using Atollic TrueStudio as an IDE, purely because of its free version, with a still unlimited code size. But quickly moved over to IAR Workbench when I realised the company had a licence for it. However, at home I will continue to use Atollic, as I’m not currently prepared to pay for an IAR licence myself. The difference using a fully functional IDE made was unbelievable, I could black box my code in ways I couldn’t with Arduino, and I could flick between files and search for declarations with ease. But the main turning point was the debugger.

Having never used a debugger before it took a while till I understood what all the functions did, and how I could use them. I spent a lot of time putting the equivalent of ‘Serial.println’ statements throughout my code. But once I’d got my head around how powerful a tool it was, I couldn’t go back.

An STM32F3 bard with integrated STLink

The SMT32F3 Discovery

I’ve since developed several projects with work, and found myself ever more hooked by this chipset. The libraries provided are great, and the resources for learning are readily available. And if you don’t want to make too big a step from Arduino, there’s HAL – the hardware abstraction layer, which is easy to set up with STMCube, and provides a huge set of functionality.

So now I’ve found myself landed with a project bigger than I’ve ever done before. This is the thousands of lines, multiple interface, optimisation heavy project I described above, and it requires a new workhorse. The SMT32F3 chip just doesn’t have the grunt. So in comes the STM32F723, an ARM Cortext-M7 beast of a processor with a 216MHz clock.

A de-cluttered platform for the SMT32F723

STM32F723 Development Board

STM32F723 – The Development Board

Above is the PCB that I’ll be using to write this project – a home brew development board which brings all of the power of the STM32F723 and none of the clutter provided on the official development board. It has a power supply, a USB interface, an SWD header for the STLink-V2 – which may become a full JTAG header further down the line, and basically nothing else. It should provide a great platform for me to develop from and if it works, I’ll be bringing it to Doayee as a fully fledged product. So all those people who put down those little blue Arduino boards in search of something else, can pick up a slightly bigger, and much more powerful, little blue board.

Posted in Blog.

2 Comments

  1. You might want to learn the difference between the possessive pronoun (its) and the contraction of ‘it is’ (it’s) as you seem to be confused. Very odd for someone with a university education!

    ” …. I really can’t sing its (no apostrophe in the possessive pronoun) praises enough …. ”

    ” … partly because of its (same again) free version … ”

    Also, you misspelled the word licensing!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.