Trust, but Verify: Examining the Output of an Embedded Compiler
I work with motor control firmware on the Microchip dsPIC33 series of microcontrollers. The vast majority of that firmware is written in C, with only a few percent in assembly. And I got to thinking recently: I programmed in C and C++ on an Intel PC from roughly 1991 to 2009. But I don’t remember ever working with x86 assembly code. Not once. Not even reading it. Which seems odd. I do that all the time with embedded firmware. And I think you should too. Before I say why, here are...
Optimizing Optoisolators, and Other Stories of Making Do With Less
It’s been a few months since I’ve rolled up my sleeves here and dug into some good old circuit design issues. I started out with circuit design articles, and I’ve missed it.
Today’s topic will be showing you some tricks for how to get more performance out of an optoisolator. These devices — and I’m tempted to be lazy and call them “optos”, but that sounds more like a cereal with Greek yogurt-covered raisins — are essentially just an LED...
[ C Programming Techniques: integer type optimization ]
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...
Surprising Linux Real Time Scheduler Behavior
I have recently been helping with embedded software design and development for a data acquisition and visualization device. The software executes within an embedded Linux context and consists of various animated user interfaces rendering the acquired data.
The data is received via a UART and a SPI connection. During project development we noticed poor UART data latency issues during heavy user interface animations. For this product to properly meet its acquisition requirements, the UART...
Embedded Firmware Refactoring, Optimisation and Migration
Legacy products are often based on older hardware platforms which often become under-powered or run out of memory which constrains further product development. Customers are always looking for new features and improved performance but often either don’t want to invest in new hardware or need to retain the current field population of devices.
These are ongoing challenges for any product manufacturer, but are particularly highlighted in embedded systems where product...
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.
My friend, the compiler
Modern compilers were given great powers, but we don't always know where and when they'll use them. This may cause us to either worry needlessly or trust unjustifiably, as demonstrated by a little example in this post.
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.
Flood Fill, or: The Joy of Resource Constraints
When transferred from the PC world to a microcontroller, a famous, tried-and-true graphics algorithm is no longer viable. The challenge of creating an alternative under severe resource constraints is an intriguing puzzle, the kind that keeps embedded development fun and interesting.