embedded c

C vs Embedded C

Embedded systems exist in our cars, refrigerators, washing machines, telephones, televisions, mixer etc. practically everywhere. Embedded C is the most popular language used to program the processor and controllers used in these systems. So what is embedded C and how is it different from actual C?

Many developers believe – It’s not about the language – it’s about how you apply the language! There is nothing called Embedded C. There is only one C language. If C is used on computers it is called regular C, while if C is used in electronics it is called embedded C.

Essentially, embedded C is an extension of the C programming language. Because of this reason, many engineers and developers do not recognise embedded C as a different language.

In 2008, the C Standards Committee extended the C language to address issues that existed between C extensions for different embedded systems by providing a common standard for all implementations to adhere to. And they named it embedded C. It includes a number of features not available in normal C, such as fixed-point arithmetic, named address spaces, and basic I/O hardware addressing.

Though C and embedded C may sound different, they have more similarities than differences. Embedded C uses most of the syntax and semantics of standard C, e.g. variable definition, datatype declaration, structures and union, bit operations, macros, function, conditional statements, loops, etc.

Key Differences:

  • C is generally used for desktop computers, while embedded C is used for microcontroller based applications.
  • C uses the resources of a desktop PC like RAM(in GBs), ROM(in GBs), OS. While, embedded C has exposure to limited resources, such as RAM(in kBs), ROM(in kBs or MBs), I/Os on an embedded processor.
  • Embedded C includes extra features such as fixed-point types, multiple memory areas, and I/O register mapping.
  • C Compilers typically generate OS dependent executables like a file with .exe extension (for windows OS). Compilers for Embedded C create files with .hex extension that can be downloaded to the microcontrollers/microprocessors.
  • The application written in embedded C, starts when the system starts, and never ends until the system stops – there is no user to run the application(like in OS based C), it does not finish, and there is nothing to return to if it were to “finish”.

According to my experience as a C developer and many other in this field, what basically is different while programming with embedded C is the mindset. For embedded applications, we need to optimally use the resources, make the program code efficient, and satisfy real-time constraints, if any. Programming wise I feel there is no line bifurcating the two, they are one and the same. The added features we get in embedded C are obtained by libraries that are written in C itself. So don’t be afraid of Embedded C. If you know C in and out, you very much know Embedded C aswell.

Leave a Reply

Your email address will not be published. Required fields are marked *