In part 2 we wrote a Makefile to build the project, configured the system clock and created a basic blink application. So far, we have built the project without the C standard library by invoking gcc with the -nostdlib flag. In this article we are going to take a look at how to integrate the C standard library into our project and set up printf() to send messages to our host machine via UART for some primitive debugging capabilities.
Category: Firmware
STM32 without CubeIDE (Part 2): CMSIS, make and clock configuration
In part 1 we did the absolute minimal setup necessary to program our MCU. We manually defined the addresses of peripheral registers and invoked the compiler and debugger directly from the command line with a rather long list of arguments. In this post we are going to make things a bit easier for ourselves. In…
STM32 without CubeIDE (Part 1): The bare necessities
Ever since I started programming microcontrollers, I have almost exclusively done so using a vendor-provided (usually Eclipse-based) IDE, which does a lot of stuff automagically behind the scenes. But since I like to know how stuff works I figured I would ditch the IDE and try starting from scratch. In this blog post series I am going to go back to basics and explore how to program an STM32 microcontroller, starting as simple as possible and then gradually adding more and more stuff along the way. In this first post I am going to start off with nothing more than an editor and the command-line.
Project Smart Greenhouse (Part 2): Data collection with ESP32
In part 1 I presented the general idea for the Smart Greenhouse. In this part I am going to get my ESP32 development board up and running and start logging some data to an online database.
Project Smart Greenhouse (Part 1): The idea
I have enjoyed gardening as a hobby for the past few years and I have two raised vegetable beds in our front yard. This year I decided to buy a greenhouse! Although I enjoy keeping a vegetable garden and watching my plants grow, constantly tending to the plants can become quite a chore. So as an engineer, of course I have to build something to facilitate the process a bit. Cue the Smart Greenhouse!
C++ and STM32CubeMX code generation
I spend most of my time writing C code for STM32 microcontrollers. I have recently considered writing more code in C++, mainly for easier implementation of various design patterns and especially for using abstract classes for dependency injection when writing testable modules/classes. However, when using STM32CubeMX to generate hardware initialization code, there is no option…
Unit testing in STM32CubeIDE with GoogleTest
Unit testing has become an essential part of developing high-quality, reliable and maintainable software, but is not as commonplace in the firmware industry as it ought to be. If you are tired of being slowed down by the “build-flash-debug” style of development, waiting for hardware or having to share hardware with several other coworkers, then off-target unit testing and test-driven development is for you!
Interfaces in C
Interfaces are an extremely useful tool to develop loosely-coupled, testable software. In the embedded world it will even allow us to write firmware and run it on our development PC instead of the actual hardware, which may be scarce or not even produced yet.
Multiple instances of a module in C
When writing modules for your application, sometimes it might be enough to have just a single instance of the module (e.g. a global “logging” module), but oftentimes you will need to create multiple instances of a module (e.g. a “queue” module). In this article I will take a look at various ways to implement this in C.
The ‘volatile’ qualifier
When programming embedded systems in C, you will most likely have stumbled upon the volatile keyword in a variable declaration. But what does this actually mean – and when should you use it?