Skip to main content

Microcontrollers

Chapter 14 C for Embedded Systems

The C programming language is an invaluable tool for programming microcontrollers using a high-level language. As introduced in SectionΒ 1.3, writing C programs for embedded systems is quite different from writing programs for general computing applications. This chapter is not intended to serve as an exhaustive reference for C; it will merely outline the most important concepts in programming C for microcontroller applications.
When writing out values in C, prefixes can be used to denote the number system of a value. If no prefix is used, the value is assumed to be in decimal (base 10). If the prefix 0b is used, the value is assumed to be in binary (base 2). If the prefix 0x is used, the value is assumed to be in hexadecimal (base 16).
C code can contain comments. These are portions of the code that will be ignored by the compiler. A comment is indicated by two forward slashes: //.