Chapter 12. Software and Coding

This chapter investigates software- and code-related issues within the context of embedded systems. Topics include:

  • What programming languages are used

  • When an operating system (OS) is needed

  • Understanding the difference between real-time and general-purpose operating systems

  • Which real-time operating systems are suitable for use

  • Configuring the ports of a microcontroller (MCU)

  • Creating device driver code

  • Defensive coding for systems functioning under adverse conditions

With coverage of these topics, a designer with coding skills should have the knowledge required to configure and program embedded systems.

Remember, this book focuses on embedded system electronics, not the coding for embedded systems. There are many books on embedded system coding out there, and several good coding references and study textbooks are suggested in “Further Reading”.

Consequently a tutorial for writing a “Hello World!” program for an embedded system isn’t included here.

Coding Languages

The approach to programming an embedded system will usually take one of three paths:

Define a state machine

For field-programmable gate array (FPGA) and complex programmable logic device (CPLD) programming, the logic structure usually defines a state machine. The state machine applies conditionals to define state changes. For this, the programming uses a hardware description language (HDL), typically Verilog or VHDL.

Use Assembly language

Simple MCUs (peripheral interface controllers, ...

Get Applied Embedded Electronics now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.