sort by category
If you are using an RTOS in your latest design then no doubt you have an idle task. (Most of the time, the idle task is explicit and is the user task with the lowest priority; sometimes it's built into the RTOS). It's been my experience that the idle task is an interesting beast. On the one hand it is what gets executed when there's nothing else to do, and thus inherently contains nothing directly related the product. On the other hand it's this wonderful resource that you can exploit to do all ...
When developing embedded code for devices with non-trivial user interfaces, it often pays off to build a prototype (virtual prototype) of the embedded system of a PC. The strategy is called "dual targeting", because you develop software on one machine (e.g., Windows PC) and run it on a deeply embedded target. Dual targeting is the main strategy for avoiding the "target system bottleneck" in the agile embedded software development, popularized in the book "Test-Driven Development for Embedded C" ...
Dead code is source code that is not executed in the final system. It comes in two forms. First, there is dead code that is commented out or removed via #ifdef's. That dead code has no corresponding form in the binary. Other dead code is present in the binary but cannot be or is never invoked. Either way, dead code is a vestige or unnecessary part of the product.
One of the places I have seen a lot of dead code is in my work as an expert witness. And I've observed that the presence of d...
One of the consequences of being in the consulting business is that I get to look at a lot of code written by other people. Usually it is necessary for me to get up to speed on the code as quickly as possible, and so to this end, one of the first things I do is look for main.c, or if it doesn't exist the file that contains main(). Here's what I usually find:
Possibly a one line description.
As part of my New Year's resolution for 2013, I just started to teach an Embedded C Programming Course with ARM Cortex-M on YouTube. The playlist for this course is available at: http://www.youtube.com/playlist?list=PLPW8O6W-1chwyTzI3BHwBLbGQoPFxPAPM .
The course is intended for beginners and is structured as a series of short, focused, hands-on lessons that teach you how to program ARM Cortex-M microcontrollers in C.
I've designed this course not just to be watched, but to follow it along...
Part of what makes embedded systems fun for me is that they normally interact with the physical world. The physical world contains real parameters which we measure using transducers, signal conditioning circuits and so on, such that ultimately we end up with a variable in our embedded code that purports to represent this real world parameter. For example, we might have this:
uint16_t pressure; /* Pressure */
Don't laugh. I have seen this a million times. What's wrong with this you ask? Wel...
Regular readers of this blog will no doubt have noticed the paltry number of articles posted by me this year. While there have been a number of contributing factors, one of the more significant has been Toyota. I have been part of the team that has spent a large part of 2012 examining the engine control module hardware and firmware for Toyota cars and light trucks in light of reports on unintended acceleration. Yesterday, a tentative settlement was announced in the class action lawsuit. Other li...
In the ten months since forming Barr Group, I have received many questions about the new company. As we enter the new year, I thought it a good time to use this blog post to answer the most frequently asked questions, such as:
What does Barr Group do?
Who are Barr Group's clients?
How is Barr Group different than my former company?
Who is our CEO and what skills does he bring?
What is my role in Barr Group?
If I had to describe Barr Group (http://www.barrgroup.com) in a sing...
Below are the top 10 most read blog posts from the Embedded Gurus in 2012.
#1: Efficient C Tip #13: Use the Modulus (%) Operator with Caution
#2: A Tutorial on Lookup Tables in C
#3: Combining C's volatile and const Keywords
#4: A Tutorial on Signed and Unsigned Integers
#5: What Belongs in a C .h Header File?
#6: Computing Your Stack Size
#7: Is "(unint16_t) -1" Portable C Code?
#8: The Absolute Truth About abs()
#9: Do Inline Function Bodies Belong in C Header Files?...
Christmas is right around the corner and if you wonder about the presents, I have just an idea for you. No, it is not the new iPad, Galaxy S3 phone, or any of the new "ultrabooks". In fact, this is exactly the opposite. My present idea is to boost your productivity in creating "content", not merely consuming it.
And when it comes to creating anything with a computer, you need a big screen--the bigger the better. In fact, I'd recommend that you get yourself two new monitors. And don't think s...
C's volatile keyword is a qualifier that can be used to declare a variable in such a way that the compiler will never optimize away any of the reads and writes. Though there are several important types of variables to declare volatile, this obscure keyword is especially valuable when you are interacting with hardware peripheral registers and such via memory-mapped I/O.
Sometimes a memory-mapped I/O device could be as simple as just having a single 8-bit control register at a fixed address. ...
Dear reader, it has been over six months since my last blog post. My apologies for being absent without leave from this blog and from my Firmware Update e-newsletter. I have never been as busy, professionally, as over the past 14 months.
I recognize I have been quiet for too long for many of you and note that several readers have written to ask if I am okay or what is keeping me so busy. I am thankful for your concern and also for your patience. I hope this will be the first of several bl...
There are a few sacred tenets of employment. One that has been emphasized to some extent at every one of my many jobs has been that your salary is a private matter. Most companies don't bother to explain why – it's just taken as common sense. Well, something I learned many years ago is there's nothing so uncommon as common sense.
Consider what may happen if every engineer knew the salary of their coworkers. You may feel disenfranchised to find your boss makes three times as much a...
I recently had lunch with a friend I hadn't seen for a while. He was still at the company where we'd worked together some years ago but had started looking for a new job. After ten years at the same company he was no longer excited by the projects. He wanted something new and more exciting.
I was entertained for the first half hour by his stories about the craziness of job interviewing. One company told him he didn't have enough management experience (he has 20 years) and another told...
With all due apologies to George Orwell for the title, I thought I'd offer a little tidbit on the practice of the following construct:
a = b = c = d = 0;
This code declares four variables (a,b,c,d) and sets them all equal to 0. The question is, is this a good, bad or indifferent practice? Well, I think it is an excellent practice in one very limited case, but otherwise should be avoided. Consider these two examples:
#define MAX_SPD (42U)
uint8_t spd1 = MA...
In the last couple of years I have had a large number of folks end up on this blog as a result of search terms such as "what does 0X47u mean?" In an effort to make their visit more productive, I'll explain and also offer some thoughts on the topic.
Back in the mists of time, it was considered perfectly acceptable to write code that looks like this:
unsigned int foo = 6;
Indeed I'm guessing that just about every C textbook out there has just such a construct somewhere in its first few chapte...
It seems there was recently a security breach at Yahoo that exposed more than 400,000 login credentials. When this is reported, it seems to always be accompanied by advice on making high quality passwords.
Well, I have a password question that challenges conventional password wisdom. I know some of the readers of this site are experts in this sort of thing, so hopefully someone will answer my question.
Not using passwords that contain your dog's name or the names o...
I read in the paper that, due to the persistently slow economy, QE3 is now a definite possibility. In case you've been living under a rock for the last few years, QE is Quantitative Easing – and we've already had two of them. This is where the government gives money to banks (well, technically they buy financial things like bad loans from the banks… look it up). Anyway, they give money to banks in the hope that the banks use that money to make loans to build new things thereby creating...
Listed below are three statements. Based on my nearly thirty years in the embedded space I can confidently state that: One I have never heard stated. Another I have rarely heard stated, and the third I hear a lot. Here they are in order:
I write crap code.
You know so-and-so. (S)he writes really good code.
This code is complete crap.
If your experience comports with mine, then it leads to what I have coined the 'crap code conundrum'. In short, crap code is everywhere - but no one admi...
In Chapter 11 of the "Test-Driven Development for Embedded C" book, James Grenning discusses the S-O-L-I-D rules for effective software design. These rules have been compiled by Robert C. Martin and are intended to make a software system easier to develop, maintain, and extend over time. The acronym SOLID stands for the following five principles:
S: Single Responsibility Principle
O: Open-Closed Principle
L: Liskov Substitution Principle
I: Interface Segregation Principle
D: Dependency I...