3 Examples of Better Embedded Coding With MISRA

Embedded code is in countless systems today. And that code needs to be right — or it could compromise safety and security.

Why Embedded Systems Developers Need Reliable Code

Embedded code powers the world’s most important systems.

It’s used in:

Automobiles people drive every day.

Heart monitors (and other medical devices) that keep people alive.

Airplanes that fly around the world.

Coding errors are not an option.

That’s why embedded programming needs to comply with guidelines. This ensures code is safe, secure, and reliable. But these guidelines can vary based on the programming language used.

2 Key Programming Languages For Embedded Systems

Most embedded systems are programmed in C and C++.

That’s because C and C++ permit low-level control of hardware. C and C++ can support the complexity of embedded programming. At the same time, using these languages leads to efficient code.

Plus, there’s a large percentage of C/C++ programmers. And they can maintain optimal performance — which is key for embedded systems.

Using MISRA For Embedded Coding in C and C++

Many embedded industries have strict compliance standards for safety and security. And these standards often require the use of a coding standard.

There are several different coding standards available for C and C++. But MISRA® is one of the most trusted coding standards. MISRA rules ensure that code complies with industry standards. It helps you reduce cyclomatic complexity. And it improves the quality of the code.

Here are three examples of how embedded developers in different industries use MISRA for better coding.

1. MISRA for Better Embedded Coding in Automotive

Automotive developers trust MISRA to ensure better code. That’s because MISRA is the benchmark of quality and compliance in the automotive industry.

“MISRA is recognized as the de facto benchmark and has been adopted throughout the Japanese automotive industry, spanning the complete supply chain from the OEMS right down to the silicon level."

ISO 26262 Compliance

The automotive industry needs to comply with ISO 26262, a functional safety standard.

ISO 26262 has strict requirements for four Automotive Safety Integrity Levels (ASIL) — A through D. It recommends using a coding standard to ensure compliance with ASIL — and highlights the MISRA coding standard.

2. MISRA For Better Embedded Coding in Rail

Railway system developers also trust MISRA for better code.

“MISRA is the obvious choice. Originally created by the automotive industry, it is one of the longest established and most respected standards, and has been widely adopted across multiple safety-related markets.”

Quality — Even in Auto-Generated Code

Selex ES also uses Helix QAC and MISRA C and C++ rules to ensure quality in its embedded programming. They even use it on auto-generated code. This means they can ensure code quality — and accelerate development times.

How to Achieve MISRA Compliance

To comply with the MISRA coding standard, you need to apply MISRA rules. This could be done manually during code reviews. Or it could be automated using a static code analyzer.

However, not all static code analyzers are the same. And when it comes to MISRA, some tools are more accurate than others. Helix QAC, for example, is the most accurate static analyzer for MISRA C and C++.

Richard Bellairs

Product Marketing Manager, Perforce

Richard Bellairs has 20+ years of experience across a wide range of industries. He held electronics and software engineering positions in the manufacturing, defense, and test and measurement industries in the nineties and early noughties before moving to product management and product marketing. He now champions Perforce’s market-leading code quality management solution. Richard holds a bachelor’s degree in electronic engineering from the University of Sheffield and a professional diploma in marketing from the Chartered Institute of Marketing (CIM).