Writing embedded software might sound easy until you run into issues such as memory leaks, real-time control loops taking 20 ms instead of 1 ms, synchronization issues occurring on the communication channels or the processors simply getting stuck by some magical powers. To provide some guidance and share my embedded software development experience with others I decided to create a tutorial for any embedded beginner or more advanced software gurus who want to dive into the embedded world. This tutorial will have a few units, starting from the most basic but yet really important aspect of processor-specific compilation, through setting the interrupts, to checking for memory leaks and abstracting hardware.
For the purpose of this tutorial, I used Linux and CLI tools for cross-compilation. Cross-compilation means compiling for a different platform than the compiler is running on. The target device I used was STM32F407VG, which is the microcontroller with the onboard Cortex M4 processor.
For easier navigation and simplified learning I divided this tutorial into a few categories. All of them are supported with the code written in C. You can either follow the tutorial in a sequence or jump into the parts of interest
- Cross-compilation for STM32F407xx
- Setting up clocks and SysTick using HAL libraries
- Debugging with JTAG
- Communication with your device over UART
- Filtering signals
- Abstracting hardware
- Test-driven development
- Controlling a Brushed DC motor
- Running embedded application without hardware
- Introduction to RTOS
First things first
The beauty, as well as the drawback of embedded software, is the fact that it requires hardware. In this tutorial you will see that in many cases you can test your code’s functionality without the hardware. However, the goal of writing embedded software is to deploy it later on the physical device.
To take the full advantage of this tutorial you will need a few toys listed below
1. Discovery board
A discovery board is the development kit developed by STMicroelectronics showcasing their family of STM32 microcontrollers. This tutorial will use a kit with the STM32F407VG microcontroller connected to a few LEDs, accelerometer and headers. Therefore, you can play with the existing devices or connect your sensors/actuators. It also contains an interface for debugging and flashing the software. It contains everything you need to start implementing your own software and be able to use many features available on Cortex M4 processor.
Where to buy: discovery board
2. Debugger
A debugger provides the hardware interface to the microcontroller that allows running the software step-by-step. You can use it stop the execution of your program at any point. You can also set the breakpoints to understand current computations or the stack state. Although using the debugger is not necessary to write firmware, it becomes an insightful tool when things go wrong. You will want to use it to check what is actually happening on the hardware and not only.
Where to buy: in-circuit debugger
Recent Comments