embedded software boot camp

Recent Posts

sort by category

Combining C's volatile and const Keywords

Does it ever make sense to declare a variable in C or C++ as both volatile (i.e., "ever-changing") and const ("read-only")? If so, why? And how should you combine volatile and const properly? One of the most consistently popular articles on the Netrino website is about C's volatile keyword. The volatile keyword, like const, is a type qualifier. These keywords can be used by themselves or together in variable declarations. I've written about volatile and const individually before. If yo...

Most Popular Embedded Gurus Blog Posts of 2011

Below are the top 10 most read blog posts from the Embedded Gurus in 2011. #1: Efficient C Tip #13: Use the Modulus (%) Operator with Caution #2: A Tutorial on Lookup Tables in C #3: Unintended Acceleration and Other Embedded Software Bugs #4: Don't Follow These 5 Dangerous Coding Standard Rules #5: Protothreads versus State Machines #6: What Belongs in a C .h Header File? #7: Computing Your Stack Size #8: Do Inline Function Bodies Belong in C Header Files? #9: The N_E...

Simplify, then add lightness

As 2011 draws to a close I have reason to be thinking about things automotive. As part of my musings, I was reminded of the famous mantra espoused by the late Colin Chapman of Lotus Cars - 'Simplify, then add lightness'. I have always liked this aphorism for its idea of 'adding lightness' rather than 'subtracting weight'. So what's this got to do with embedded systems you ask? Well, when it comes to embedded systems programming, I think Chapman's concept is spot on. While most people would pr...

Novel uses for RTC registers

For obvious reasons, I usually write about things that are widely applicable. Today I'm going to deviate from this slightly and talk about the real time clock registers / RAM that are available on some (many?) ARM processors as well as I suspect a number of other architectures. An excerpt from the NXP data sheet is shown in the figure below. [caption id="attachment_672" align="aligncenter" width="704" caption="NXP LPC17xx RTC registers"][/caption] Of most interest is the column labeled 'Re...

The Personal Computer vs. The Chemistry Set

Recent (and much needed) basement cleaning uncovered a treasure trove of childhood chemistry set experimenter books. Back in the day, there was no Internet.  The only hope for young chemists looking for new experiments was to troll bookstores and newsstands.  Fortunately, chemistry sets were relatively popular when I was a kid and a number of authors produced books for this audience. [caption id="attachment_119" align="alignleft" width="398" caption=""The Golden Book of Chemistry Ex...

Continuing Education

I've had a couple of teachers in my family for several years.  Recently I became aware (well, I started paying attention to) the rather stringent requirements for teachers' continuing education.  The specifics of the requirements vary depending on the system in which the teacher works, but the intent of the rules is universal.  That is, you can't teach youngsters – disabled, gifted, or normal, unless: You periodically demonstrate you haven't forgotten all you were taught. You are regu...

Apple After Steve Jobs

Sadly, Mr. Jobs is with us no more.  Not too long ago I did a commentary on the state of Microsoft after the departure of Bill Gates so it seems only fair that I do one on Apple after Steve Jobs… Except we don't know yet.  We don’t know what the future holds for Apple.  So instead I'll present some challenges Apple will face as they move forward without the guidance of Steve Jobs. But first a brief history – I was fortunate to see Bill Gates in person twice.  Once he bought me a ...

An open letter to the developers of the MPLAB IDE

I recently inherited a project that uses a Microchip PIC18 processor. Without going into too much detail, suffice it to say that I ended up using Microchip's MPLAB IDE Version 8.73 together with Microchip's C compiler. It had been a number of years since I last used MPLAB, in part because my experience back then was so painful. I was heartened to see that the version number had jumped from 6.X to 8.X and so I was fully expecting to find an IDE that was at the very least, decent. Boy was I disapp...

Firmware Forensics: Best Practices in Embedded Software Source Code Discovery

Software has become ubiquitous, embedded as it is into the fabric of our lives in literally billions of new (non-computer) products per year, from microwave ovens to electronic throttle controls. When products controlled by software are the subject of litigation, whether for infringement of intellectual property rights or product liability, it is imperative to analyze the embedded software (a.k.a., firmware) properly and thoroughly. This article enumerates five best practices for embedded soft...

What's the state of your Cortex?

Recently, I've been involved in a fascinating bug hunt related to a very peculiar behavior of the ARM Cortex-M3 core. Given the incredible popularity of this core, I thought that digging a little deeper into the mysteries of ARM Cortex could be interesting and informative. First, I need to provide some background. So, the bug was related to the very unique ARM Cortex-M exception type called PendSV. This is an exception triggered by software, but unlike any regular software interrupt, PendSV i...

Effective C Tip #9 – use #warning

This is the ninth in a series of tips on writing effective C. Way back in 1999 I wrote an article for Embedded Systems Programming concerning the #error directive. If you aren't particularly familiar with #error, then I suggest you read the article. While the #error directive has remained one of my most popular tools, I have become an equally big fan of #warning. Before I delve into the uses of #warning, I must warn you (if you would pardon the pun) that #warning is a non standard directive. ...

Don't Follow These 5 Dangerous Coding Standard Rules

Over the summer I happened across a brief blog post by another firmware developer in which he presented ten C coding rules for better embedded C code. I had an immediate strong negative reaction to half of his rules and later came to dislike a few more, so I'm going to describe what I don't like about each. I'll refer to this author as BadAdvice. I hope that if you have followed rules like the five below my comments will persuade you to move away from those toward a set of embedded C coding r...

Rabbit patches and embedded systems

You may think from the title that I'm writing about Rabbit microprocessors - but no I'm actually intending to talk about bunnies. What you ask do rabbits have to do with embedded systems? Well read on and find out... If you have ever had a vegetable garden then you will know that they are magnets for rabbits. Furthermore, you will soon find out that it takes extraordinary efforts to keep the rabbits out, as they have a tremendous ability to circumvent all sorts of fences.  When faced with su...

On the Origin of Software by Means of Artificial Selection

If you haven't put your hands on the recent James Grenning's book "Test-Driven Development for Embedded C" yet, I highly recommend you do. Here is why. First, you need to realize that this book is not really about testing--it is about software development. The central idea behind TDD (Test-Driven Development) is that software, as any complex system in nature, has to evolve gradually and has to keep working throughout all the development stages. This idea is of course not new and goes back a...

Getting The UI Right

Hey – we're engineers, not artists, so why ever would you want us to do a user interface?  Well, one reason is possibly that we're the only game in town. I've lived through a number of situations where I, or a coworker, was asked to do a user interface.  Often (usually…) management would assert, "Don't worry, this is just for a demo" or "Just throw it together quickly so we have something to use for testing".  OH! But how many times we ended up actually delivering the "expedient" UI be...

How to lockup the in-flight entertainment system on a Boeing 777

I have recently returned from  a short trip to the UK. I flew both ways on what appeared to be a relatively new Boeing 777 courtesy of  United Airlines. As is now common place on trans-Atlantic wide-body aircraft, my seat came with its own in-flight entertainment system. After I took my seat to fly to London, I was a little surprised to see that the in-flight entertainment system was suddenly rebooted. How did I know this? Well there was cute Linux penguin in the top left hand corner, plus I (...

How to Enforce Coding Standards Using PC-Lint

In an earlier blog post, I introduced the concept of automatic enforcement of coding standards by stating that: Enforcement of coding standards too often depends on programmers already under deadline pressure to be disciplined while they code and/or to make time to perform peer code reviews. ... To ensure your selected coding standard is followed, and thus effective, your team should find as many automated ways to enforce as many of its rules as possible. And you should make such automated rule...

Condition Based Maintenance For Automotive Systems

Modern cars have dozens of embedded systems – from adjusting the air/fuel mixture to preventing the brakes from locking – it seems nearly everything in the car is controller by embedded software. This folks, is a revolution.  For a hundred years the automotive industry struggled to beat mechanical complexity into submission.  As progress was gradually made the demands on drivers became progressively less.  Early drivers had to be tinkerers with a toolkit and mechanical aptitude.  Toda...

Protothreads versus State Machines

For a number of years I've been getting questions regarding Protothreads and comparisons to state machines. Here is what I think. Protothreads are an attempt to write event-driven code in a sequential way. To do so, protothreads introduce a concept of "blocking abstraction" to event-driven programming--something that event-driven programming is trying to get rid of in the first place. Obviously, to be compatible with event-driven programming, protothreads cannot *really* block, at least no...

Is an RTOS really the best way to design embedded systems?

Recently I've been involved in a discussion on the LinkedIn Real-Time Embedded Engineering group, which I started with the question "Is an RTOS really the best way to design embedded systems?". The discussion, which has swollen to over 0xFF comments by now, has sometimes low signal to noise ratio, but I believe it is still interesting. I consider this discussion to be a continuation of the topic from my April blog post I hate RTOSes. As before, my main point is centered on the funda...