Coding Step 1 - Hello World and Makefiles

Stephen Friederichs February 10, 2015

My previous article discussed how to install GCC and the make utility with the expectation of writing and compiling your first C program. In this article, I discuss how to use those tools we installed last time. Specifically, how to use GCC to compile a C program and how to write a makefile to automate the process.

While there are many other tutorials out there covering roughly similar ground, I hope that you (a novice with some background in programming) find this tutorial to be more useful and approachable than...

Coding - Step 0: Setting Up a Development Environment

Stephen Friederichs November 25, 20142 comments

You can easily find a million articles out there discussing compiler nuances, weighing the pros and cons of various data structures or discussing the  optimization of databases. Those sorts of articles are fascinating reads for advanced programmers but completely leave in the dust many others. Others asking very basic questions such as ‘How do I use a compiler?’ or ‘How can I code without an IDE?’ These basic questions deserve good answers because they represent the absolute first step that everyone has to take before they can become a veteran programmer:...

Project Directory Organization

Stephen Friederichs August 20, 20142 comments

A recent question on Reddit’s C Programming sub asked what sort of directory structure people use for their projects. Perhaps not unsurprisingly this didn’t elicit a flood of answers - maybe there are no organizational schemes that people are happy with or perhaps few people consider it a glamorous topic (not that the C Programming subreddit is filled with glamorous people -no offense I love you all). Personally I find it to be a very...

Short Circuit Execution vs. Unit Testing

Stephen Friederichs July 7, 20143 comments

The key to effective communication is to say what you mean and avoid ambiguity.  Words and phrases with multiple meanings can confuse your audience and hinder communication. That’s why so many programmers prefer writing code to writing specifications: written human language introduces ambiguity and subsequently, confusion. Code only has one interpretation, period. This doesn’t, however, ensure that the right message is getting through. Code can, indeed, only do one thing, but that doesn’t mean it does what the programmer intended it would.  Take, for example,...

10 Items of Test Equipment You Should Know

Jason Sachs June 22, 20141 comment

When life gets rough and a circuit board is letting you down, it’s time to turn to test equipment. The obvious ones are multimeters and oscilloscopes and power supplies. But you know about those already, right?

Here are some you may not have heard of:

Non-contact current sensors. Oscilloscope probes measure voltage. When you need to measure current, you need a different approach. Especially at high voltages, where maintaining galvanic isolation is important for safety. The usual approach is a current transformer, perhaps with a Hall-effect sensor for...

How to make a heap profiler

Yossi Kreinin May 23, 2014

We'll see how to make a heap profiler. Example code for this post makes up heapprof, a working 250-line heap profiler for programs using malloc/free.

It works out of the box on Linux (tested on "real" programs like gdb and python). The main point though is being easy to port and modify to suit your needs. The code, build and test scripts are at github.

Why roll your own heap profiler?

  • It's easy! And fun, if you're that sort of person. What, not reasons enough? OK, how about...
  • Your platform...

How to Include MathJax Equations in SVG With Less Than 100 Lines of JavaScript!

Jason Sachs May 23, 20143 comments

Today’s short and tangential note is an account of how I dug myself out of Documentation Despair. I’ve been working on some block diagrams. You know, this sort of thing, to describe feedback control systems:

And I had a problem. How do I draw diagrams like this?

I don’t have Visio and I don’t like Visio. I used to like Visio. But then it got Microsofted.

I can use MATLAB and Simulink, which are great for drawing block diagrams. Normally you use them to...

Using a RTLSDR dongle to validate NRF905 configuration

Fabien Le Mentec January 27, 20146 comments
I am currently working on a system to monitor the garage door status from my flat. Both places are 7 floors apart, and I need to send the data wirelessly. I chose to operate on the 433MHz carrier, and I ordered 2 PTR8000 modules: PTR8000 is based on the dual band sub 1GHz NRF905 chipset from NORDICSEMI:

Energia - program a TI MSP430 using Arduino sketches

Lonnie Honeycutt November 5, 20131 comment
TI MSP430 Launchpad

I started tinkering with microcontroller a couple of years ago with an Arduino Uno.  I had a little experience with C, so programming in the Arduino environment has been relatively easy and straightforward for me.  My code is not necessarily elegant or efficient, but I can usually figure out how to make an Arduino do what I want it to do eventually.  A lot of credit to the Arduino userbase, as it is very easy to figure most things out with a quick Google search when you get stuck.

Not long after I started tinkering with the Arduino, I...

Delayed printf for real-time logging

Yossi Kreinin October 25, 20132 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 the event type, and a few variables depending on the type. This is fast, but not...