EmbeddedRelated.com

In the beginning, there was no code…

James Grenning August 16, 20233 comments

…and it was good.

Why is it that code starts out nice and deteriorates over time?


Getting Started With Zephyr: Devicetree Bindings

Mohammed Billoo August 16, 2023

This blog post shines some light on how devicetrees are used in The Zephyr Project. Specifically, we understand the mechanisms that enable us to use nodes in the devicetree in the C source files. We use a sample provided in the Zephyr repository itself and work our way through portions of the Zephyr codebase to get insight into the mechanisms that make this possible.


Quaternions and the spatial rotations in motion enabled wearable devices. Exploiting the potential of smart IMUs attitude estimation.

Pablo Perez Garcia August 10, 20238 comments

Have you always wondered what a quaternion is? this is your post. Attitude or spatial orientation analysis is a powerful element in wearable devices (and many other systems). Commercially available sensors can provide this information out-of-the-box without requiring complex additional implementation of sensor fusion algorithms. Since these are already on-chip solutions devices can serve as a way to explore and analyze motion in several use cases. Mathematical analysis for processing quaternion is presented along with a brief introduction to them, Although they are not really easy to visualise, a couple fairly simple examples are provided which may allow you to gain some intuition on what's the logic behind them.


From Embedded Software Engineer to Musician

Jean Labrosse August 7, 2023

In his first blog post on EmbeddedRelated, Jean Labrosse, the author of the uC/OS series and founder of Micrium, discusses his transition from an embedded software engineer to a musician.


Bit-Banged Async Serial Output And Disciplined Engineering

Steve Branam August 3, 2023

This post covers implementing asynchronous serial output directly on a GPIO with bit-banging. This can be a valuable debug tool for getting information out of a system. It also covers disciplined engineering, using the bit-banging module as an example and template you can apply to other projects.


Jumping from MCUs to FPGAs - 5 things you need to know

Duane Benson July 31, 2023

Are you a microcontroller expert beckoned by the siren song of the FPGA? Not long ago, that was me. FPGA-expert friends of mine regularly extolled the virtues of these mysterious components and I wanted in. When I made the leap, I found a world seemingly very familiar, but in reality, vastly different. I found that my years of C programming and microcontroller use often gave pre preconceived interpretations of FPGA resource material which resulted in eye-roll class mistakes in my code. I’ve gleaned five things of vital importance to help you make that transition faster than I did.


Assembly language is best - except when it isn’t

Colin Walls July 27, 20231 comment

A look at why writing in C often produces more efficient code than hand-written assembly language.


C to C++: 5 Tips for Refactoring C Code into C++

Jacob Beningo July 23, 20235 comments

The article titled "Simple Tips to Refactor C Code into C++: Improve Embedded Development" provides essential guidance for embedded developers transitioning from C to C++. The series covers fundamental details necessary for a seamless transition and emphasizes utilizing C++ as a better C rather than diving into complex language features. The article introduces five practical tips for refactoring C code into C++. Replace #define with constexpr and const: Discouraging the use of #define macros, the article advocates for safer alternatives like constexpr and const to improve type safety, debugging, namespaces, and compile-time computation. Use Namespaces: Demonstrating the benefits of organizing code into separate logical groupings through namespaces, the article explains how namespaces help avoid naming conflicts and improve code readability. Replace C-style Pointers with Smart Pointers and References: Emphasizing the significance of avoiding raw pointers, the article suggests replacing them with C++ smart pointers (unique_ptr, shared_ptr, weak_ptr) and using references


Why Should Unit Tests Feel Like Simulations?

Amar Mahmutbegovic July 23, 2023

Unit tests are designed to test units of software, but what exactly is a unit of software? It can be a function or a method, a class, or even an entire module. 

If you're just starting with unit testing, chances are you're testing the implementation of a function or a method. Consequently, if the implementation changes, you must update your tests as well, which can render the entire process pointless. This is often the case with small pieces of code, particularly in embedded development,...


Getting Started With Zephyr: Devicetrees

Mohammed Billoo July 18, 20232 comments

This blog post provides an introduction to the "Devicetree", another unique concept in The Zephyr Project. We learn about the basic syntax of a device tree and how its structure and hierarchy mirror hardware, from the SoC to the final board. We also see how hardware described in a devicetree can be referenced and controlled in the source code of a Zephyr-based application.


PID Without a PhD

Tim Wescott April 26, 201614 comments

I both consult and teach in the area of digital control. Through both of these efforts, I have found that while there certainly are control problems that require all the expertise I can bring to bear, there are a great number of control problems that can be solved with the most basic knowledge of simple controllers, without resort to any formal control theory at all.

This article will tell you how to implement a simple controller in software and how to tune it without getting into heavy...


From Baremetal to RTOS: A review of scheduling techniques

Jacob Beningo June 8, 201617 comments

Transitioning from bare-metal embedded software development to a real-time operating system (RTOS) can be a difficult endeavor. Many developers struggle with the question of whether they should use an RTOS or simply use a bare-metal scheduler. One of the goals of this series is to walk developers through the transition and decision making process of abandoning bare-metal thinking and getting up to speed quickly with RTOSes. Before diving into the details of RTOSes, the appropriate first step...


Introduction to Microcontrollers - Button Matrix & Auto Repeating

Mike Silva November 12, 2013

Too Many Buttons, Not Enough Inputs

Assigning one GPIO input to each button can use up a lot of GPIO pins.  Numeric input requires at least 10 buttons, plus however many additional control or function buttons.  This can quickly get expensive, GPIO pin-wise, and also connector-wise if the keypad is off the uC PCB as it often would be.  A very common response to this expense is to wire buttons (keys, etc) in a matrix.  By connecting our buttons in an...


Round Round Get Around: Why Fixed-Point Right-Shifts Are Just Fine

Jason Sachs November 22, 20163 comments

Today’s topic is rounding in embedded systems, or more specifically, why you don’t need to worry about it in many cases.

One of the issues faced in computer arithmetic is that exact arithmetic requires an ever-increasing bit length to avoid overflow. Adding or subtracting two 16-bit integers produces a 17-bit result; multiplying two 16-bit integers produces a 32-bit result. In fixed-point arithmetic we typically multiply and shift right; for example, if we wanted to multiply some...


Which MOSFET topology?

Jason Sachs September 1, 20119 comments

A recent electronics.StackExchange question brings up a good topic for discussion. Let's say you have a power supply and a 2-wire load you want to be able to switch on and off from the power supply using a MOSFET. How do you choose which circuit topology to choose? You basically have four options, shown below:

From left to right, these are:

High-side switch, N-channel MOSFET High-side switch, P-channel MOSFET Low-side switch, N-channel...

BGA and QFP at Home 1 - A Practical Guide.

Victor Yurkovsky October 13, 20134 comments

It is almost universally accepted by the hobbyists that you can't work with high-density packages at home.  That is entirely incorrect.  I've been assembling and reflowing BGA circuit boards at home for a few years now.  BGAs and 0.5mm-pitch QFPs are well within the realm of a determined amateur. 

This series of articles presents practical information on designing and assembling boards with high-density packages at home.  While the focus is on FPGA packages, most of...


Embedded Toolbox: Programmer's Calculator

Miro Samek June 27, 20178 comments

Like any craftsman, I have accumulated quite a few tools during my embedded software development career. Some of them proved to me more useful than others. And these generally useful tools ended up in my Embedded Toolbox. In this blog, I'd like to share some of my tools with you. Today, I'd like to start with my cross-platform Programmer's Calculator called QCalc.

I'm sure that you already have your favorite calculator online or on your smartphone. But can your calculator accept...


Development of the MOS Technology 6502: A Historical Perspective

Jason Sachs June 18, 20223 comments

One ubiquitous microprocessor of the late 1970s and 1980s was the MOS Technology MCS 6502. I included a section on the development of the 6502 in Part 2 of Supply Chain Games, and have posted it as an excerpt here, as I believe it is deserving in its own right.

(Note: MOS Technology is pronounced with the individual letters M-O-S “em oh ess”,[1] not “moss”, and should not be confused with another semiconductor company,


Introduction to Microcontrollers - 7-segment displays & Multiplexing

Mike Silva August 14, 20142 comments

Doing the 7 Segment Shuffle

The 7 segment display is ubiquitous in the modern world.  Just about every digital clock, calculator and movie bomb has one.  The treadmills at my gym have 6 or 7, each one displaying 3 or 4 digits.  What makes the 7-seg interesting is that it presents an opportunity to make a trade off between GPIO (output pins) for time.  Every 7-seg display requires 8 outputs (the 7 segments and usually either a decimal point or a...