Which programming language is used in the computer of a car?

After work today, I was reading about the throttle response adjustmentprocedure to mitigate turbo lag in the 3.5 EcoBoost F-150. For the non car nerds, I’ll save you a click – it’s just a way to re-calibrate the electronically controlled engine throttle, making it feel more responsive when the gas pedal is pressed. Nearly every part of a car is computer controlled or monitored these days, so I got to wondering…what computer language(s) do Ford and other manufacturers use to write the software that is used by the car’s computer?

Some quick Googling indicated that C is overwhelming used in car electronic control modules. This makes sense as C is very common in embedded systems because it provides easy access to hardware, has low memory usage, and most importantly – it’s fast. Auto manufacturers use a specific implementation of C known asMISRA-C(Motor Industry Software Reliability Association C). MISRA-C is actually a set of guidelines for programming in C that helps avoid bad code which could cause dangerous behavior while a car is in operation. I’m not a C programmer and a lot of this goes over my head, but MISRA-C is just a rigidly defined programming style. When implemented, it will ensure that common errors and pitfalls programmers can make will be avoided entirely when writing software for a car computer.

According to Wikipedia, MISRA-C was originally targeted at the automotive industry, but it has evolved as a widely accepted model for best practices by embedded systems developers in other industries including aerospace, telecom, defense, railway, and others. Pretty cool stuff! If you’re interested, here is some more reading on programming car computers:

Rule 59 (required): The statement forming the body of an “if”, “else if”, “else”, “while”, “do … while”, or “for” statement shall always be enclosed in braces. Basically, this says that from now you must clean up your act, you can’t write sloppy things like the else clause in following example:

if (x == 0)
{
y = 10;
z = 0;
}
else
y = 20;

The idea of this rule is to avoid a classical mistake. In the example below the line z = 1; was added. It looks as though it’s part of the else clause but it’s not! In fact, it is placed after the if statement altogether, which means that the assignment will always take place. If the original else clause would have contained the braces from the beginning this problem would never have occurred.

Matt Callahan

Welcome to my blog. I am a software developer in Phoenix, AZ and this is my place to post interesting or funny stuff I’ve found about programming, GIS, computers, cars, radios, or whatever. Visit my homepage at mfcallahan.com