How-to Articles | Barr Group

15 min read Original article ↗

Arizona Lottery's Not-So-Random Number Generator

Posted October 12, 2017

Random numbers -- really, truly random numbers -- play a very important role in security.  Unfortunately, they are also common sources of non-random behavior, as in the Arizona Lottery drawing.

Introduction to Rate Monotonic Scheduling

Posted November 08, 2016

If you've got a lot of real-time tasks and tight deadlines, what's the best way to prioritize them? Rate Monotonic Algorithm provides the optimal technique.

Security and the IoT

Posted October 25, 2016

In a recent DDoS attack, devices such as webcams and DVRs were used to launch an attack on domain service provider, Dyn. The enormity of this event brings to light the importance of securing all devices capable of connecting to the Internet.

Top 5 Causes of Nasty Embedded Software Bugs

Posted May 05, 2016

Too often engineers give up trying to discover the cause of infrequent anomalies--because they can't be easily reproduced in the lab--dismissing them as "user errors" or "glitches." Yet these ghosts in the machine live on. So here's a guide to the most frequent root causes of difficult-to-reproduce firmware bugs.

How to Allocate Dynamic Memory Safely

Posted May 04, 2016

Whether you're using only static memory, a simple stack, or dynamic allocation on a heap, you have to proceed cautiously. Embedded programmers can't afford to ignore the risks inherent in memory utilization.

How to Protect Non-Volatile Data

Posted May 04, 2016

Unexpected power loss and software bugs can undermine the reliability of non-volatile data. Fortunately, there are various ways to make non-volatile data resilient to such corruption.

How to Avoid Common Firmware Bugs

Posted May 04, 2016

Understanding software and hardware bugs in other embedded systems can help you identify, diagnose, and fix bugs in your own.

Design by Contract for Embedded C

Posted May 04, 2016

What is the Design by Contract programming philosophy, what can it do for you, and why should all embedded software developers care?

How to Code a State Machine in C or C++

Posted May 04, 2016

A state machine is any object that behaves different based on its history and current inputs.  Many embedded systems consist of a collection of state machines at various levels of the electronics or software.

How to Have Polymorphism Without a Heap

Posted May 04, 2016

Rethinking basic programming techniques can avoid many of the problems that heap-based memory management poses for embedded real-time system designs.

How to Install and Configure the RedBoot ROM Monitor

Posted May 04, 2016

RedBoot is a portable, open-source ROM monitor that offers a download and debug environment. What more could you want?

Many embedded developers today use a ROM- or flash-resident software program that provides functionality such as loading and running application software, scripting, read/write access to processor registers, and memory dumps. A ROM monitor, as it is often called, can be a useful and far less expensive debugging tool than an in-circuit emulator.

How to Port the eCos Operating System

Posted May 04, 2016

The first task when using any new real-time operating system (RTOS) is to get it up and running on your hardware. The open-source eCos RTOS makes that part pretty easy.

Mutexes and Semaphores Demystified

Posted May 04, 2016

In this first installment of a series of articles on the proper use of a real-time operating system (RTOS), we examine the important differences between a mutex and a semaphore.

2016 Survey of Embedded Systems Design Trends

Posted January 14, 2016

According to a recent survey, there are "10" types of people in this world: those who understand binary and those who don't. 

As you are presumably (by nature of being reading this niche blog) one of the former and also experienced in the art of embedded systems design, won't you please participate in a quick online survey regarding trends in our industry:

Software Reliability and the Internet of Things

Posted January 07, 2016

As Internet connectivity advances, the transportation, automotive, medical device, smart grid and other industry sectors have become more dependent on embedded software. But is software reliable?

Reduce Energy Use via Power Debugging

Posted January 10, 2011

According a recent study by the European Union, approximately 10% of electricity used in homes and offices is 'vampire power'. That is to say that even when many products, especially embedded systems, are turned "off" they are still consuming power! The same report puts the total amount of energy wasted in this way, within Europe alone, at dozens of Terawatt hours per year.

Top 10 Causes of Nasty Firmware Bugs

Posted December 15, 2010

Finding and killing latent bugs in embedded software is a difficult business. Heroic efforts and expensive tools are often required to trace backward from an observed crash, hang, or other unplanned run-time behavior to the root cause. In the worst case scenario, the root cause damages the code or data in a subtle way such that the system still appears to work fine or mostly fine--at least for a while.

How to Minimize Interrupt Service Routine (ISR) Overhead

Posted January 01, 2007

With all the automation available today, it's easy for programmers to overlook costly overhead introduced into machine code by the compiler. Interrupt handlers are one key area worthy of a closer inspection.

Usability Standards for Medical Devices

Posted May 01, 2006

Examining the structure of the ANSI and ISO usability standards is the first step to developing medical devices that protect users from accidents.

The Perils of Preemptive Multitasking

Posted January 01, 2006

Every commercial RTOS employs a priority-based preemptive scheduler. This despite the fact that real-time systems vary in their requirements and real-time scheduling doesn't have to be so uniform. Multitasking and meeting deadlines is certainly not a one-size-fits-all problem.

How to Handle User Errors

Posted June 01, 2005

With thoughtful design, user interfaces for embedded systems can avoid some user errors altogether and helpfully guide the user through the rest.

How to Use C's offsetof() Macro

Posted March 01, 2004

C's offsetof() macro can be a helpful addition to your bag of tricks, including for packing data structures and describing how EEPROM data are stored.

Introduction to Controller Area Network (CAN)

Posted August 01, 2003

Controller Area Network (CAN) is the most widely-used automotive bus architecture. Here are some reasons why.

At peak, some automobiles contained up to three miles of cabling. To reduce the cost and weight of wiring and still allow ECUs to become more intelligent, new methods had to be found to reduce the amount of wiring. The CAN bus has since found application in other industries as well.

Introduction to On-Chip Debug

Posted March 01, 2003

Motorola's Background Debug Mode is one of a variety of on-chip debug technologies. Collectively, they offer some of the best features of debug monitors and in-circuit emulators—with far less headache and cost.

How to Choose a Real-Time Operating System

Posted January 01, 2003

In the market for a real-time operating system (RTOS)? This article provides an overview of RTOSes and how you can select the best one for your project.

Optimal C Constructs for 8051 Microcontrollers

Posted October 01, 2002

The limitations of an 8-bit microcontroller (MCU) can sometimes make conventional C constructs produce suboptimal code. In this article we look at common problems on the 8051 family and discuss workarounds in C.

Introduction to Counter/Timer Hardware

Posted September 01, 2002

Counter units (aka, timer units) are crucial components of most embedded systems and included in many microcontrollers. Here's a primer on the hardware.

Introduction to Closed-Loop Control and PID

Posted August 01, 2002

Most control systems utilize feedback in some manner. Here's a look at several fundamental feedback mechanisms, culminating in a description of a basic PID controller.

MISRA-C Guidelines for Safety Critical Software

Posted July 01, 2002

In 1998, the UK's Motor Industry Software Reliability Association established a set of 127 guidelines for the use of C in safety-critical systems. Here's a look at the rules, what they mean, and how they can work for you.

KVM: A Small Java Virtual Machine for J2ME

Posted June 01, 2002

Sun's K Virtual Machine gives embedded developers a virtual kick in the pants. KVM makes it possible to, for the first time, run Java programs on any 16-bit processor with 128KB of available memory.

How to Use Lint for Static Code Analysis

Posted May 01, 2002

Language specifications, including those for C and C++, are often loosely written. A static analysis tool called lint can help you find dangerous and non-portable constructs in your code before your compiler turns them into run-time bugs.

Introduction to Priority Inversion

Posted April 01, 2002

When tasks share resources, as they often do/must, strange things can and will happen. Priority inversions can be particularly difficult to anticipate. A basic understanding of the problem is key.

How to Detect Memory Leaks

Posted February 01, 2002

Memory leaks can be particularly risky for long-running embedded systems. Here are some tools to identify, track, and analyze memory leaks in embedded C and C++ programs.

Introduction to Watchdog Timers

Posted October 01, 2001

For those embedded systems that can't be constantly watched by a human, watchdog timers may be the solution.

Most embedded systems need to be self-reliant. It's not usually possible to wait for someone to reboot them if the software hangs. Some embedded designs, such as space probes, are simply not accessible to human operators. If their software ever hangs, such systems are permanently disabled. In other cases, the speed with which a human operator might reset the system would be too slow to meet the uptime requirements of the product.

Introduction to Pulse Width Modulation (PWM)

Posted September 01, 2001

Pulse width modulation (PWM) is a powerful technique for controlling analog circuits with a processor's digital outputs. PWM is employed in a wide variety of applications, ranging from measurement and communications to power control and conversion.

How to Use C's volatile Keyword

Posted July 01, 2001

The proper use of C's volatile keyword is poorly understood by many programmers. This article will teach you the proper way to do it.

How and When to Use C's assert() Macro

Posted March 01, 2001

The assert() macro is one of those simple tools that would not seem to merit an entire article, but I have come across an alarming number of engineers who have not heard of it or do not use it.

How to Use Strings to Internationalize C Programs

Posted February 01, 2001

Products destined for use in multiple countries often require user interfaces that support several human languages. Sloppy string management in your programs could result in unintelligible babble.

How to Use Watchdog Timers Properly when Multitasking

Posted November 01, 2000

To keep a watchdog timer from resetting your system, you've got to kick it regularly. But that's not all there is to watchdog science. We will examine the use and testing of a watchdog, as well as the integration of a watchdog into a multitasking environment.

How Network Processors Work

Posted November 01, 2000

Network processors are programmable chips like general purpose microprocessors, but are optimized for the packet processing required in network devices. But what are they good for and how do they work?

Fast Accurate Memory Test Code in C

Posted July 01, 2000

If ever there was a piece of embedded software ripe for reuse it's the memory test. This article shows how to test for the most common memory problems with a set of three efficient, portable, public-domain memory test functions.

Address Resolution Protocol (ARP)

Posted July 01, 2000

The address resolution protocol provides a necessary bridge between physical and logical addresses on a TCP/IP network.

Every system on a TCP/IP network has two addresses, one physical and one logical. The address resolution protocol (ARP) provides a necessary bridge between these two addresses.

How Ethernet's MAC Addresses Work

Posted June 01, 2000

Merely adding a protocol stack and networking API to your software doesn't make you TCP/IP ready. You'll also need to assign your product a MAC address.

Any book on TCP/IP will tell you that each network-connected device has a globally unique hardware address. But where, exactly, do these addresses come from? And why is it that the authors of books on TCP/IP never bother to answer this or any other practical implementation question?

How to Calibrate Mechanical Inputs in Software

Posted May 01, 2000

Embedded software developers operate in a perfect digital environment but must interact with the imperfect analog real world. To do this it's essential to know how to perform calibration of inputs and sensors.

Assembly vs. C: Which is Best for Microcontrollers?

Posted March 01, 2000

Given a particular programming problem, what language should you use to realize the solution? Your choice could very well affect the success or failure of the project. So you'd better choose wisely.

CRC Series, Part 1: Additive Checksums

Posted November 01, 1999

What if data is lost or corrupted in transit? Communication protocols usually attempt to detect such errors automatically. To do that they use checksums.

Introduction to the ATVEF Protocol Enhanced TV

Posted October 01, 1999

New standards are making the delivery of Web-based and enhanced content alongside television a reality. This article describes the ATVEF enhanced television standard and the requirements for designing ATVEF-compatible receivers.

Short Range Wireless Protocols: Bluetooth vs. IrDA

Posted October 01, 1999

As engineers design more and more products with embedded computer systems that require connections of one sort or another, short-range wireless protocols offer an attractive alternative to wired connections.

How to Design App-Ready Embedded Systems

Posted September 01, 1999

Bug fixes, patches, and third-party application programs are all possible in today’s more powerful embedded systems, but you need to plan for them at design time. This article shows you how.

How to Use the C Preprocessor's #error Directive

Posted September 01, 1999

One of the least used but potentially most useful features of the C preprocessor is the ANSI-specified #error directive. Here's a look at a couple of clever uses for #error that have proven invaluable in embedded software development.

RS-485 Transmit Enable Signal Control

Posted August 01, 1999

Quite a few embedded systems include multiple processors. Sometimes these processors stand in isolation, but more often they're required to communicate over a multidrop bus such as EIA RS-485 or RS-422.

How Programmable Logic Works

Posted June 01, 1999

In recent years, the line between hardware and software has blurred. Hardware now engineers create the bulk of their new digital circuitry in programming languages such as VHDL and Verilog. This article will help you make sense of programmable logic.

How to Choose an Embedded C Compiler

Posted May 01, 1999

Let's face it, there's nothing sexy about the topic of cross compilers. Embedded programmers couldn't get the job done without one, but spend very little time thinking about how they work or how they could make our work easier.

Efficient C Code for 8-bit Microcontrollers

Posted November 01, 1998

The 8051, 68HC11, and Microchip PIC are popular microcontrollers, but they aren't necessarily easy to program. This article shows how the use of ANSI C and compiler-specific constructs can help generate tighter code.

Java Compilers for Embedded Systems

Posted September 01, 1998

Java compilers (also known as ahead-of-time or AOT compilers) may be the breakthrough needed to propagate widespread use of Java throughout the embedded industry.

How Reconfigurable Computing Works

Posted September 01, 1998

Designers of embedded systems face three significant challenges in today's ultra-competitive marketplace. Products must always: do more, cost less, and arrive to market faster. Fortunately, new flexible hardware design techniques are emerging from the study of reconfigurable computing.

How to Design Safer Systems via Better User Interfaces

Posted August 01, 1998

The information that a user gets from a life-critical system may spell the difference between a slight mishap and a serious accident. This article addresses the issue of safety in the design of a user interface.

How to Use Java in Embedded Systems

Posted May 01, 1997

Should you consider using Java as an embedded programming language? This article describes when and where Java works for embedded development.