I like to think I write good code, and I’ve used C and C++ almost since their inception. I admit to incorporating more than one unwanted bug into C applications that were eliminated after sometimes tedious diagnostic sessions. Almost every new microcontroller released has a free C/C++ compiler toolchain associated with it.
Unfortunately, C is very unforgiving, and C++ is only a little better. But they are the mainstay for embedded programmers these days. That’s one reason why I have been waiting for AdaCore’s delivery of its Ada 2012 toolchain for Arm’s Cortex-M platform. It is a free download at libre.adacore.com.
The Cortex-M is the main low-end, 32-bit microcontroller utilized by almost all major microcontroller vendors that have adopted the Arm architecture. Vendors like Green Hills Software, Atego, and Adacore have supported the Cortex platform in the past but with earlier Ada standards. Ada 2012 includes a range of new features including contracts (see “Ada 2012: The Joy of Contracts” on electronicdesign.com).
More Articles About Ada and SPARK
Rolling Up My Sleeves
I had already tried out a version of AdaCore’s GNAT Programming Studio (GPS). It generated applications that would run on Linux on the BeagleBone based on the Texas Instruments Cortex-A8 platform (see “ARMing Ada” on electronicdesign.com). The new toolchain targets bare metal, which is needed for many applications.
Setup was easy since GPS was already installed. Setting up the ST-Link debug interface to the STM32 board (see the figure) actually took more time. It was then a matter of running through the flashing LED demo. I included a snippet of code from a flashing LED program to highlight some of the advantages of using Ada 2012 (see the listing).