Back To Basics: MISRA Guidelines

I recently learned about the MISRA guideline and I am digging in. Thought I will share what I learned about it.

MISRA (Motor Industry Software Reliability Association) is a consortium formed in the UK automotive sector to publish best-practice coding guidelines for safety/security-critical software. It publishes coding rules that define a safe subset of the language so code behaves the same on every build and is easier to review and test.

It’s applicable for functional safety systems. Functional safety means a system stays safe even when parts fail. We design software so a single fault does not create danger. In cars, this aligns with ISO 26262. Other domains use similar safety norms.

MISRA helps by cutting out parts of the C or C++ language that are risky. These tricky parts can cause hidden bugs, memory problems, or code that’s hard to understand and test. This is a good fit for embedded systems that run for years. It makes reviews and tests sharper and gives auditors solid evidence.

It contains things for example, things like Use nullptr, not 0 or NULL. Avoid tricky casts like reinterpret_cast. Prefer smart pointers and RAII over new and delete. Do not return a pointer or reference to a local variable. Make destructors noexcept. Keep macros and globals small and controlled etc. Some 200 odd guidelines.

Current state for C++is MISRA C++ 2023 based on C++17 and influenced by AUTOSAR C++14. MISRA C 2025 exists for C. Official guideline is paid and for purchase(but cheap). The process guide MISRA Compliance 2020 is free and explains how to claim compliance, deviations, and reports. Also, AUTOSAR C++14 is free and still worth a read. Search around, you will find links talking about the guidelines in detail if you are tight on budget and not buying.

From what I understood, MISRA is not about creating zero violations. It is more about defining a clear coding process with justified deviations. I think I will start to use this more in firmware development from now on.

If you liked the post, Share it with your friends!

Back To Basics: Isolated DC-DC Converters

Let’s discuss this one today. Many people that I know don’t even know that these exist.

An isolated DC-DC converter moves power from one domain of your board to another without a galvanic connection. Input and output don’t share a ground. Energy couples through a tiny transformer, so the secondary side can float. It breaks ground loops, reduces conducted noise, and limits how faults on the primary side propagate downstream. So you can use this in your circuits where you want to transport power and be potentially safe. Think about the cases where you might have High voltage on one part of the circuit and low voltage on the other part & you want separate them. 

So how does it work? A MOSFET switch chops DC into high frequency to drive a small transformer. The secondary rectifies and filters it back to DC. Flyback stores energy while on and releases it when off.

Typical use cases where you would use them would be for sensors front ends and 4-20 mA loops, RS-485 or CAN nodes and products that must meet medical or industrial safety. You also use it to create a floating rail for level shifting. One great part is you can create negative or positive output as its floating output.

These converters are usually available as modules, and it’s worth buying rather than you spending the time designing one from scratch to use(unless you have enormous numbers). For different power ratings ranges, you will find ready-made options in SMD and through hole parts. Murata, TI and Recom are few of the players around. Make sure you size the module based on the output requirements for current and voltage. These modules don’t have very high efficiency. Typically, expect them in 60-85% range.

Anyway, keep these modules in mind when you plan to build a product which would need safety and isolation.

If you liked the post, Share it with your friends!
1 5 6 7 8 9 73