EmbeddedRelated.com
Memfault Beyond the Launch

Delayed printf for real-time logging

Yossi Kreinin October 25, 20133 comments

You often debug by adding a few printfs and looking at the logs. In some real-time/low-level contexts though, you don't have time for text formatting.

You don't want prints to affect timing too much, because then timing-related bugs you're chasing might disappear. And you certainly don't want the system to stop functioning altogether because prints cause it to miss real-time deadlines.

A common alternative to prints is more "raw" logging - an event buffer, where event is a union keeping...


Coroutines in one page of C

Yossi Kreinin August 20, 201316 comments

A coroutine is a function that you can jump back into after returning from it - and it remembers where it was in the code, and all the variables. This is very useful at times.

One use is generating a sequence of values. Here's how you can generate all the x,y pairs in a 2D range in Python:

def iterate(max_x, max_y): for x in range(max_x): for y in range(max_y): yield x,y for x,y in iterate(2,2): print x,y

This prints:

0 0 0 1 1 0 1 1

The yield keyword is like...


Code Metrics - SLOC Count

Stephen Friederichs August 19, 2013

Many programmers will start having flashbacks at the title of this article because it contains the words 'metrics' and 'SLOC'.  Newer programmers are probably wondering what all of the fuss is about - most probably have no negative connotations with the term 'code metrics' and some may not even know what SLOC is.  While there is much baggage associated with metrics and SLOC you shouldn't be afraid to gather fundamentally useful data such as SLOC count from your programming projects...


[ C Programming Techniques: integer type optimization ]

Fabien Le Mentec May 22, 20131 comment

I am currently working on a voltage controller running on a ATMEGA328P, ATMEL AVR 8 bits microcontroller. The controller logic is implemented in the main() routine and relies on a periodical timer whose frequency is fixed at application setup. Among other things, the timer ISR handler increments some per tick counters which are then used by the main routine to implement the voltage controller timing logic.By looking at the code, one noticed that I use the uint8_t type for counters instead of...


Interfacing LINUX with microcontrollers

Fabien Le Mentec May 7, 20132 comments
Introduction

I am increasingly asked to work on small spare time projects where a user needs to control some device over the INTERNET. Recently, a friend needed to control heater relays and measure the temperature of its geographically distant secondary house. Another case relates to the control of a pan tilt home monitoring camera. A last one is the control of an old XY plotter DACs.

In both applications, the user wants to access the system over a web browser using HTTP. From the user...


C Programming Techniques: Function Call Inlining

Fabien Le Mentec April 29, 20137 comments
Introduction

Abstraction is a key to manage software systems as they increase in size and complexity. As shown in a previous post, abstraction requires a developper to clearly define a software interface for both data and functions, and eventually hide the underlying implementation.When using the C language, the interface is often exposed in a header '.h' file, while the implementation is put in one or more  corresponding '.c' files.

First, separating an interface from its...


Data Hiding in C

Stephen Friederichs April 20, 201317 comments

Strictly speaking, C is not an object-oriented language. Although it provides some features that fit into the object-oriented paradigm it has never had the full object-oriented focus that its successor C++ offers. C++ introduced some very useful concepts and abilities that I miss when I’m developing in ANSI C. One such concept is protected member variables and functions.

When you declare a class in C++ you can also declare member variables and functions as part of that class. Often, these...


Chebyshev Approximation and How It Can Help You Save Money, Win Friends, and Influence People

Jason Sachs September 30, 201220 comments

Well... maybe that's a stretch. I don't think I can recommend anything to help you win friends. Not my forte.

But I am going to try to convince you why you should know about Chebyshev approximation, which is a technique for figuring out how you can come as close as possible to computing the result of a mathematical function, with a minimal amount of design effort and CPU power. Let's explore two use cases:

  • Amy has a low-power 8-bit microcontroller and needs to compute \( \sqrt{x} \)...

Welcome to my life!

Morten Dramstad July 18, 20127 comments

Hi folks!

As an electronic engineer the most of my work is about making new designs where a microcontroller is present in 99.9 % of the applications. Since 2003 I am self-employed and do consultants work for different companies. I have been traveling to different parts of the world doing work for DeLaval International, a company that makes automation equipment for the dairy industry. A lot of the things I have done for them involves use of different Atmel AVR...


10 Software Tools You Should Know

Jason Sachs May 20, 201215 comments

Unless you're designing small analog electronic circuits, it's pretty hard these days to get things done in embedded systems design without the help of computers. I thought I'd share a list of software tools that help me get my job done. Most of these are free or inexpensive. Most of them are also for working with software. If you never have to design, read, or edit any software, then you're one of a few people that won't benefit from reading this. 

Disclaimer: the "best" software...


Embedded Software Creation II - European Normative & Legislation

Dr. Maykel Alonso December 20, 20116 comments

In this post I will explain the European Normative. I will answer the main questions and I will be open to answer all the doubts any of you could have. Please leave a comment and I will answer if i could.

Why I need to look and accomplish some standards? 

The main reason is if you want to comercialize the product in the European Union, if exists any European Directive that cover the product, the product must be marked with the CE mark. For USA it work in the same way by the...


Embedded Software Creation I - Methodologies

Dr. Maykel Alonso June 20, 20112 comments

The first knowledge we need it is to know the posibilities or methodologies that exists to create Software. Each methodology is used to develop diferent types of Software. The types usually are defined by the requeriments and the diferent normative that is related to the type of device. In the next post I will explain how to find the normative@ legislation (link), and how does it work. 

Let's start with methodologies. There are lot's of methodologies and so many people that develop...


Debugging DSP code.

Mark Browne May 1, 2019

I am fascinated with neural network processing and have been playing with them since the 80's.

I am a frequent contributor to the Numenta forum. Numenta is the current project of Jeff Hawins, the guy that gave us the Palm Pilot. They are working with the HTM model. This is a system based on studies of the functions of the cortical column and has some very interesting properties: It processes sequential data streams and has very effective one shot learning. The data is arranged in Sparse...


A true pioneer passes away... A farewell to Ritchie.

Gene Breniman October 15, 20115 comments

We all have our heroes.  We all have people who were important to our professional developments.  For me, Dennis Ritchie was one of those people.  I was an early adopter of the C programming language.  Back in the very early 80's a friend and neighbor had excitedly shared with me his copy of "The C Programming Language" by Kernighan and Ritchie.  At first I was a non-believer.  I had for several years been a happy and productive assembly language...


Simple C++ State Machine Engine

Massimiliano Pagani March 14, 2024

When implementing state machines in your project it is an advantage to rely on a tried and tested state machine engine. This component is reused for every kind of application and helps the developer focus on the domain part of the software. In this article, the design process that turns a custom C++ code into a finite-state machine engine is fully described with motivations and tradeoffs for each iteration.


Software Prototyping

Gene Breniman August 19, 20081 comment

In my recent blog entry on the product development process (way down, near the end of the entry), I wrote the following:

"I continue these sorts of tests, building more and more complexity, until I am satisfied that my circuit is basically functional. Then, using the test code that I have created as a model, I begin to write the real software for my product. As my software grows, to complete the full functionality of my design, I sometime find it useful to drop back to my 'test software'...


Tracing code and checking timings

Richard Dorfner May 25, 20115 comments

Debugging resource limited systemsApplications writers that write code on large systems have it easy. Well, perhaps not easy, but certainly easier. There are some things that they don't have to worry about and there is a huge array of tools available to them when it comes time to debug. The have choices in their toolsets, lots of choices. They also have a large selection of available methods for getting debugging information out to them such as log files, proc entries, pop up dialog boxes or...


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.


Building Linux Kernel for Desktops

Kunal Singh August 9, 20084 comments

Linux Development has made an amazing process in last decade. Different Linux Distributions come with specific tools which greatly ease down the build process for Linux Kernel.

Here is a good introduction to these build tools and build procedure for different Linux Distributions:

Building Kernel for Fedora

Building Kernel for Ubuntu

Building Kernel for Suse...


Embedded Developers, Ditch Your IDEs – Here’s Why!

Amar Mahmutbegovic September 25, 20231 comment

Ditching your Integrated Development Environment (IDE) temporarily can be a transformative learning experience in embedded development. This post invites you to explore the underpinnings of IDEs by delving into alternative tools and processes like Makefile, CMake, Vim, GDB, and OpenOCD. Understanding these tools can demystify the background operations of IDEs, revealing the intricacies of compiling, linking, and debugging. This journey into the “under the hood” aspects of development is not just about learning new tools, but also about gaining a deeper appreciation for the convenience and efficiency that IDEs provide. By stepping out of your comfort zone and experimenting with these alternatives, you can sharpen your skills, enhance your knowledge, and possibly discover a more tailored and streamlined development experience. Whether you're a novice or a seasoned developer, this exploration promises insights and revelations that can elevate your embedded development journey.


Memfault Beyond the Launch