RSS Feed

Coding in C

C is a widely used programming language. It originated in the UNIX world and became a de facto standard for programming microcontrollers. Approximately 30 years ago microcontrollers were mainly programmed in Assembler. This was good enough for small applications and is still the right choice for 4bit controllers and other small applications like e.g. the PIC10 series. However for more complex applications programming in Assembler is difficult.

C proved to be a good substitute. It allows structured programming and the overhead it generates compared to pure Assembler programming is not too big. However, there are a few pitfalls related to C-programming. Solutions were established to make C programming more safe. These pitfalls are addressed by the MISRA standard and were published in various books. My section on the safe programming in C tries to summarize this issue.

Other programming languages do not seem to gain ground against C in the microcontroller world. There are attempts to introduce C++ or Java, but only a small segment of microcontroller applications makes use of these languages. The additional overhead they generate seems to avoid a wider use. It seems that the complexity of software in the microcontroller world can be still handled well enough in C. The resource issue is always a hot spot. Memory and CPU power cost money and since microcontroller applications tend to be produced in high volumes, every Cent saved in the design makes a difference in the profit of a product. A balance seems to be established between complexity, the tool(s) to handle it (the C compiler), and the price for memory and CPU power. So it seems that C will be still the first choice for some years to come.