While planning a book on programming microcontrollers I’ve been trying to settle on a small group of microcontrollers that could be used for examples. Every couple of years I do this to myself. Below are a few examples, including the ubiquitous Arduino UNO with an 8-bit chip, as well as the FRDM-KL25Z and Adafruit Metro M0 Express boards with ARM Cortex chips. It’s also possible to create simple designs using a breadboard and stand-alone chips, as you can see in the breadboard illustration with three chips: two PIC16s and one ATMEGA328. In the book I’d like to contrast C code on three or four platforms, perhaps two 8-bit PIC/AVR and two 32-bit ARM Cortex examples per concept. It’ll be a challenge to keep things compact, but the exercise might prove beneficial for understanding (and catching errors!).
I’ve created a table to compare and contrast a short-list of candidates. The emphasis is on trying to find an “out-of-the-box” product that would permit a student or self-learner with minimal experience to get up-and-running quickly. Hardware should be complete and boards should be available from reputable vendors, including resellers and should be relatively inexpensive. Serial monitors are not considered appropriate, so a debugging port (e.g. ICSP, JTAG or SWD) is required. If construction is required, then breadboarding is favoured over soldering. For this reason, the 8-bit PIC and AVR solutions on breadboard are preferred over off-the-shelf boards that require soldering of debug headers. Fritzing parts files are a bonus because it’ll make it easier to create illustrations (board view and schematics).
I’ve got over this process a few times in the past few months. I’m thinking that my choice is boiling down to this:
- ATMEGA 328 (breadboard and Arduino). It’s just so popular, so by including it the audience is broader and deeper. By showing the breadboard version it helps get at the idea that the microcontroller is the chip, not the board. MPLAB X support, now available, is better than AVR Studio or command-line gcc, making it better for novices who want/need to go beyond the Arduino IDE. Plus, a lot of current material online relies on the old tools. Time for an update.
- PIC16. This, and the 68HC11, are the 1990s version of the Arduino. The PIC16s, in spite of being much maligned, are widely used, well documented, simple and the IDE is free, multiplatform and holistic (simulator and debugger support). As of 2018, the IDE (MPLAB X) now supports ATMEGA and SAMD, too, but the support for PIC is better for the time being. PIC16F84A, while old, is a really simple chip and has basic PICKit3 debugger support, making a good target for examining disassembled code, as well as assembler from scratch. I’m trying it out for a course at INSA Strasbourg in the Fall of 2018. The PIC16F1619 is a new generation alternative with a new core and new peripherals on a cheap Curiosity board with built-in debugger, making breadboard or premade boards good options, depending on the learner.
- Cortex M0+. I initially rejected this back around 2008 in my former job because the teaching material and hardware were not ready for pedagogical primetime, much to the chagrin of my “oh shiny!” obsessed colleagues. Ten years later, my tune has changed. Cheap boards, with built-in debuggers and really good IDE+compilers from NXP and Microchip are responsible for this. The NXP FRDM KL25Z (or alternatively the FRDM KL22F with soldered SWD port), and the Adafruit Metro M0 Express or Microchip SAMD21 Xplained provide professional grade debugging hardware in ultra-cheap boards. Wonderful.
I’d like to use Arduino-brand Cortex boards because of the recognition that the Arduino brand brings, but it’s clear that Massimo and company have had a lot of trouble selling and supporting their ARM products. Maybe they’re victims of the success of their ATMEGA-based products or maybe there is some complex issues with development or supply chain that I can’t fathom, but their history is not good when it comes to ARM. So alternatives from other companies like Microchip, Adafruit and NXP are likely to be better.
While there are five or six variants of hardware to examine, only two IDEs (MPLAB X and MCUXpresso) need to be used for creating examples. MPLAB X supports more chips (PIC16, ATMEGA and SAMD) but it is limited to the C90 and C99 C programming standards, whereas MCUXpresso can go up to C14, as shown below. If necessary, the SAMD and Kinetis parts could be tested using the open source project GNU MCU Eclipse, which might support a more current version of the C standard (C++, too).
The more words I write here the more I realize that the breadth of example hardware might be too much. (This post was supposed to take an hour but I’ve spent the better part of a day on it… an indication of things to come?) But it should be easy to cut back if I see that, right?