ARM Cortex-M Thread Mode vs Handler Mode Explained

When working with ARM Cortex-M microcontrollers, understanding how the processor executes application code and responds to interrupts is very essential. A Cortex-M processor spends most of its time executing application code. However, when an interrupt or another exception occurs, the processor must temporarily suspend its current execution, handle the event, and then resume the interrupted

ARM Cortex-M Thread Mode vs Handler Mode Explained Read More »

Electrical Fast Transient (EFT) Testing: IEC 61000-4-4 and Practical EMC Design Guidelines

Electrical Fast Transient (EFT) testing is an essential electromagnetic compatibility (EMC) immunity test used to evaluate whether electronic equipment can operate reliably in the presence of repetitive, fast electrical disturbances. Defined by IEC 61000-4-4, this test simulates transient interference associated with electrical switching operations, relay contact arcing, and the interruption of inductive loads. In industrial

Electrical Fast Transient (EFT) Testing: IEC 61000-4-4 and Practical EMC Design Guidelines Read More »

Designing High-Speed SPI: The Pitfalls of Open-Drain Buffers and Pull-Ups

Serial Peripheral Interface (SPI) is widely used in embedded systems to communicate with  external Flash memory, displays, ADCs, sensors, and other peripherals. Its simple architecture, full-duplex communication, and support for high data rates make it a popular choice in microcontroller-based designs. Configuring an SPI peripheral is usually straightforward. Select the clock frequency, configure the clock

Designing High-Speed SPI: The Pitfalls of Open-Drain Buffers and Pull-Ups Read More »

When UART Talks to Itself: The Optical Probe Loopback Bug Nobody Expects

During the development of optical communication firmware for smart meters, a strange field issue was reported: “Communication randomly drops. Works perfectly on the bench. Fails in the field.” To investigate the issue, I swapped cables, verified baud rates, and analyzed logic analyzer captures frame by frame. Everything appeared correct until I noticed that the optical

When UART Talks to Itself: The Optical Probe Loopback Bug Nobody Expects Read More »

C Macro Override Bug: When #define Breaks Build System Configuration

In embedded firmware development, configuration is often controlled through compiler macros passed from the build system. This keeps the codebase flexible and allows easy customization for different products or hardware variants. In this blog post, we will explore how a macro can introduce a subtle bug, often referred to as a C macro override bug

C Macro Override Bug: When #define Breaks Build System Configuration Read More »

How to Detect Bit Changes in C/C++ Using the XOR Operator and Bit Masking

When working with C or C++, particularly in embedded systems and firmware development, the ability to detect bit changes in C/C++ is essential. Because instead of writing: bool flag1; bool flag2; bool flag3; bool flag4; bool flag5; bool flag6; In embedded systems, we often store multiple related status flags inside a single variable. Generally, we

How to Detect Bit Changes in C/C++ Using the XOR Operator and Bit Masking Read More »