top of page
  • Writer's pictureMARY PRINCY R

C Programming for Embedded Systems -1

Updated: Feb 1, 2023



This is my first post under the category of C programming for embedded systems. In terms of embedded systems, I am a novice. Thus, this blog series is meant for beginners. The intended audience includes high school students, college students, hobbyists, and anybody else interested in learning about embedded systems. I expect on the readers of this blog to have a fundamental understanding of the C programming language. So, let's all learn together.


Learning Objectives:

  • Why is C used in embedded systems?

Why C?

Before the C language was introduced to microcontroller-based systems, programs were written using assemblers and burned into EEPROMs. There was no mechanism to find what the program was doing. LEDs, switches etc., were used to check the correct execution of program. Microprocessor-specific and assembly-only programming languages became less popular over time. C was adopted by embedded systems.


C is a general-purpose computer programming language that may be utilized in a wide range of applications. It used to create operating systems and application software for computers and embedded systems. Despite being created more than fifty years ago, there isn't a programming language that even comes close to C when it comes to embedded systems. Let's look at the reasons that make C the most prominent language for embedded systems.


  • Portability

Code written in C is more adaptable and can be compiled on different platforms with less modifications. A program can be written on one system and executed on other systems.

Assume that the current microcontroller is no longer in use and cannot be produced. In this situation, we must transfer our source code to the new microcontroller, the available cross compiler takes care of many interoperable issues. If the language does not support portability, we may have to restart product development.

  • Processor independent

C language is platform independent whereas the applications written in C are not. It is not specific to any microprocessor/micro-controller or any system. It can work on different hardware setups. Running a program in C doesn't require the same hardware.

  • Bit manipulation

C is a flexible, structured language that provides "low level bit wise data manipulation" using the bitwise operators. Bitwise operators come handy when it comes to embedded systems, for instance when handling registers.

  • Memory Management

We can directly access memory using pointers and perform various operations using them.

When the amount of memory needed is unknown, it can be allocated dynamically; otherwise, it can be allocated statically.

  • Performance

C code is compiled into a raw binary executable that can be loaded into memory and executed immediately. C offers optimized machine instructions for the given input, which increases the performance of the embedded system. High-level languages typically rely on libraries; therefore, they use more memory, which is a big challenge in embedded systems.

  • Maintainability

In the C programming language, there are numerous compile-time directives that help maintain the source code version. The primary keywords used at compile time are " # if, # else, # elif,# endif, # define, # def, # ndef etc. Using these keywords, the user can do version control to make good working code.


Characteristics of Embedded Programming Environment

  • Limited memory

  • Hardware oriented programming.

  • Critical timing.

  • Many different pointer types.

  • Special keywords and tokens.


Keys to create successful embedded C program.

  • Good understanding about the system architecture.

  • Good understanding about the tools used for programming/debugging.

  • Knowledge about the native data types supported.

  • Understand the difference between simple v/s efficient coding.


Happy learning!!!!





37 views0 comments

Recent Posts

See All
bottom of page