Three more things you need to know when transitioning from MCUs to FPGAs
Take a look at three more important difference between FPGAs and MCUs: "code reuse" vs templating, metastability and blocking vs. non-blocking operations.
In the beginning, there was no code…
…and it was good.
Why is it that code starts out nice and deteriorates over time?
Getting Started With Zephyr: Devicetree Bindings
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.
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
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
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
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
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++
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?
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,...
C++ Assertion? Well Yes, But Actually No.
Assertions are a double-edged sword - on one side you enforce program correctness catching bugs close to their origin, on the other your application is subject to run-time error, like any interpreted language. This article explores what C++ can offer to get the advantages of assertions, without risking the crashes by moving contract checking at compile time.
Free Goodies from Embedded World - What to Do Next?
I told you I would go on a hunt for free stuff at Embedded World in order to build a bundle for someone to win.
You Don't Need an RTOS (Part 3)
In this third article I'll share with you a few cooperative schedulers (with a mix of both free and commercial licenses) that implement a few of the OS primitives that the "Superduperloop" is currently missing, possibly giving you a ready-to-go solution for your system. On the other hand, I don't think it's all that hard to add thread flags, binary and counting semaphores, event flags, mailboxes/queues, a simple Observer pattern, and something I call a "marquee" to the "Superduperloop"; I'll show you how to do that in the second half of this article and the next. Although it will take a little more work than just using one of the projects above, it will give you the maximum amount of control over your system and it will let you write tasks in ways you could only dream of using an RTOS or other off-the-shelf system.
PID Without a PhD
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...
C to C++: Bridging the Gap from C Structures to Classes
In our last post, C to C++: Proven Techniques for Embedded Systems Transformation, we started to discuss the different ways that C++ can be used to write embedded software. You saw that there is no reason to be overwhelmed by trying to adopt complex topics like metaprogramming out of the gate. An important concept to understand is that you can make the transition gradually into C++ while still receiving the many benefits that C++ has to offer.
One of the first...
Supply Chain Games: What Have We Learned From the Great Semiconductor Shortage of 2021? (Part 5)
In this article we’re going to take a look at cycle time, queues, and inventory. Cycle time is a manufacturing term — for anything, not just semiconductors — meaning how long it takes for an individual product to make its way through a manufacturing process, from start to finish. We’re going to try to understand how long it takes to manufacture semiconductors. In particular, we’re going to try to answer these questions:
- How long does it take...
The DSP Online Conference - Right Around the Corner!
It is Sunday night as I write this blog post with a few days to go before the virtual doors of the very first DSP Online Conference open..
It all started with a post in the DSPRelated forum about three months ago. We had just had a blast running the 2020 Embedded Online Conference and we thought it could be fun to organize a smaller event dedicated to the DSP community. So my goal with the post in the forum was to see if...
Cortex-M Exception Handling (Part 1)
This article describes how Cortex-M processors handle interrupts and, more generally, exceptions, a concept that plays a central role in the design and implementation of most embedded systems.
Linear Feedback Shift Registers for the Uninitiated, Part XVIII: Primitive Polynomial Generation
Last time we figured out how to reverse-engineer parameters of an unknown CRC computation by providing sample inputs and analyzing the corresponding outputs. One of the things we discovered was that the polynomial \( x^{16} + x^{12} + x^5 + 1 \) used in the 16-bit X.25 CRC is not primitive — which just means that all the nonzero elements in the corresponding quotient ring can’t be generated by powers of \( x \), and therefore the corresponding 16-bit LFSR with taps in bits 0, 5,...
Boot Sequence for an ARM based embedded system
Hello all,
Allow me to introduce myself. I am Deeksha and I come from plains of North India. My tryst with embedded technologies has been 5 years long and every single day I am amazed with the vastness and learning involved. The thing with embedded technologies is either you are into it, or you aren't. You cannot just hang around half-heartedly (I guess that holds true for every field, for that matter).You have to keep the learning and sharing process going on. And that is the reason I am...
Another 10 Circuit Components You Should Know
It's that time again to review all the oddball goodies available in electronic components. These are things you should have in your bag of tricks when you need to design a circuit board. If you read my previous posts and were looking forward to more, this article's for you!
1. Bus switches
I can't believe I haven't mentioned bus switches before. What is a bus switch?
There are lots of different options for switches:
- mechanical switch / relay: All purpose, two...
Linear Feedback Shift Registers for the Uninitiated, Part XVI: Reed-Solomon Error Correction
Last time, we talked about error correction and detection, covering some basics like Hamming distance, CRCs, and Hamming codes. If you are new to this topic, I would strongly suggest going back to read that article before this one.
This time we are going to cover Reed-Solomon codes. (I had meant to cover this topic in Part XV, but the article was getting to be too long, so I’ve split it roughly in half.) These are one of the workhorses of error-correction, and they are used in...
VHDL tutorial - combining clocked and sequential logic
In an earlier article on VHDL programming ("VHDL tutorial" and "VHDL tutorial - part 2 - Testbench", I described a design for providing a programmable clock divider for a ADC sequencer. In this example, I showed how to generate a clock signal (ADCClk), that was to be programmable over a series of fixed rates (20MHz, 10MHz, 4MHz, 2MHz, 1MHz and 400KHz), given a master clock rate of 40MHz. A reader of that article had written to ask if it was possible to extend the design to...
Free Goodies from Embedded World - What to Do Next?
I told you I would go on a hunt for free stuff at Embedded World in order to build a bundle for someone to win.
Padé Delay is Okay Today
This article is going to be somewhat different in that I’m not really writing it for the typical embedded systems engineer. Rather it’s kind of a specialized topic, so don’t be surprised if you get bored and move on to something else. That’s fine by me.
Anyway, let’s just jump ahead to the punchline. Here’s a numerical simulation of a step response to a \( p=126, q=130 \) Padé approximation of a time delay:
Impressed? Maybe you should be. This...
Second-Order Systems, Part I: Boing!!
I’ve already written about the unexciting (but useful) 1st-order system, and about slew-rate limiting. So now it’s time to cover second-order systems.
The most common second-order systems are RLC circuits and spring-mass-damper systems.
Spring-mass-damper systems are fairly common; you’ve seen these before, whether you realize it or not. One household example of these is the spring doorstop (BOING!!):
(For what it’s worth: the spring...
Cortex-M Exception Handling (Part 2)
The first part of this article described the conditions for an exception request to be accepted by a Cortex-M processor, mainly concerning the relationship of its priority with respect to the current execution priority. This part will describe instead what happens after an exception request is accepted and becomes active.
PROCESSOR OPERATION AND PRIVILEGE MODEBefore discussing in detail the sequence of actions that occurs within the processor after an exception request...
The CRC Wild Goose Chase: PPP Does What?!?!?!
I got a bad feeling yesterday when I had to include reference information about a 16-bit CRC in a serial protocol document I was writing. And I knew it wasn’t going to end well.
The last time I looked into CRC algorithms was about five years ago. And the time before that… sometime back in 2004 or 2005? It seems like it comes up periodically, like the seventeen-year locust or sunspots or El Niño,...
Best Firmware Architecture Attributes
Architecture of a firmware (FW) in a way defines the life-cycle of your product. Often companies start with a simple-version of a product as a response to the time-to-market caveat of the business, make some cash out of the product with a simple feature set. It takes only less than 2-3 years to reach a point where the company needs to develop multiple products derived from the same code base and multiple teams need to develop...
Digital PLL's -- Part 2
In Part 1, we found the time response of a 2nd order PLL with a proportional + integral (lead-lag) loop filter. Now let’s look at this PLL in the Z-domain [1, 2]. We will find that the response is characterized by a loop natural frequency ωn and damping coefficient ζ.
Having a Z-domain model of the DPLL will allow us to do three things:
Compute the values of loop filter proportional gain KL and integrator gain KI that give the desired loop natural...