Have you ever used an Arduino Mega 2560 (or a similar board) and, at some point in the development process, experienced the LED mysteriously stopping to blink, garbled text being printed, or funny artifacts appearing in pictures? And all that without any apparent reason or any error or warning message? If you want to know what is behind it and how to solve this problem, read on.
Continue readingCategory: Programming
Everything about programming
Volatility, Race Conditions, And Heisenbugs
What is the purpose of the C++ qualifier volatile? What does it have to do with race conditions, and what are Heisenbugs?
Software I2C Multiplexer
What can you do to connect many I2C devices with the same device address to an MCU? Most often, the advice is to use hardware solutions. Here, we will look at how to solve the problem with software employing the FlexWire library.
Continue reading
Replacing the Wire Library—Sometimes
The Wire library is the one that connects your Arduino to sensors and actuators that communicate using the I2C protocol. Unfortunately, this library has a lot of shortcomings, and often you want to replace it with a different I2C library. Replacing the Wire library on a per-sketch basis turns out to be more complicated than one would expect. In this blog post, I describe an easy way to accomplish that.
Continue reading
Link-Time Optimization and Debugging of Object-Oriented Programs on AVR MCUs
Link-time optimization (LTO) is a very powerful compiler-optimization technique. As I noticed, it does not go very well together with debugging object-oriented programs under GCC, at least for AVR MCUs. I noticed that in the context of debugging an Arduino program, and it took me quite a while to figure out that LTO is the culprit.
Continue reading
Real Programmers Write Assembly Code
Although the typical Arduino programmer is probably not interested in writing assembly code, in some situations assembly programming is essential. Let’s have a look at these situations and see what one can do.
Continue reading