Embedded Basics – Don’t Forget about Real-time

Microcontrollers are becoming more powerful every day, causing many developers to forget the resource constrained nature that many are working within. Microcontrollers are not general computing devices that can be treated like they have infinite memory and clock speeds equivalent to that found on modern PC’s (or cell phones). Most microcontroller based applications are designed for real-time applications.

Real-time applications have deadlines that must be met or else the system performance could degrade or worse, the system could fail! Compare a real-time system to a PC OS such as Windows, Mac OS or Linux where someone may click and wait tens of seconds before the system responds. Remember the blue screen of death or the pinwheel of death (which I still get today)? Unacceptable behavior in a real-time embedded system.

A real-time embedded system consists of two different deadline types; soft and hard real-time deadlines. Soft real-time deadlines are system timing deadlines that should always be met but if for some reason they are not met, the user or system degrades but the system overall is still functional and performs its purpose. An example for a soft real-time deadline is sampling a button for whether it is pressed or not or perhaps displaying low priority information on a monitor for a user.

A hard real-time deadline on the other hand is quite system critical. Missing a hard real-time deadline means that something catastrophic could occur to the system. For example, pressing the brake pedal and rather than responding within 100 milliseconds the brakes engaged second later. Missing the deadline is a sign that the system has failed.

Resource constrained microcontrollers have become, to quite a few developers, not so resource constrained. A decade or two ago developers commonly developed systems with a few dozen kilobytes for code space and a few kilobytes for RAM. Today, the high-end microcontrollers have a megabyte for flash space and 256 kilobytes or more RAM. Clock speeds are surpassing 200 MHz which make these microcontrollers feel like they are general purpose CPU’s where the developer no longer needs to care about system timing.

Real-time, time based, software is what real-time embedded systems are all about. Too many developers today are starting to completely ignore time. Assumptions are made that there is enough CPU horse power to handle the application and developers are starting to ignore sound engineering principles. For example, I’ve seen many systems, even high end systems, where developers arbitrarily select task priorities, neglect measuring anything time related and then are confounded when their system randomly behave unexpectedly and misses deadlines.

EVERY microcontroller is resource constrained in one form or another and it is critical that developers take the time to review their system, measure time and monitor how their tasks execute whether they are developing on a simple Cortex-M0+ or a complex Cortex-M4. Embedded software developers, new and experienced need to keep in mind that we are working on resource constrained systems and understanding the timing of every function, component and interrupt are critical to delivering a fully functional system that behaves as expected no matter the situation.

Leave a Reply

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