What is Embedded System Programming & Its Languages

A system is an arrangement of multiple units, assembled together to function according to the given instructions. An embedded system is a combination of both hardware and software, which performs a particular task within the specified period (which means it should perform only one specific task like a washing machine). The main advantage of using an embedded system in an application is that it can minimize the size and the cost and also improves the reliability and efficiency of the task. This article overviews about embedded software languages, embedded system programming, and their functions.

Components of Embedded Systems

The following are the components of embedded systems

  • Embedded Hardware: Micro-controller is the heart of the embedded system, where multiple peripherals are interfaced to embedded hardware for communication purpose.
  • Embedded RTO’s: An embedded real-time operating system is used to perform all complex (ar operations.
  • Device Drivers: It acts as a bridge between the operating systems and peripheral devices.
  • Communication stacks: It is used for communicating with external devices.
  • Embedded applications: It performs the predefined function of the embedded device.
Embedded System Components
Embedded System Components

Embedded Software

An embedded software or embedded system programming is computer software, which is used to control devices by providing a set of instructions. It is also named as firmware, various devices with various functionalities can be programmed using embedded software, by maintaining design constraints (like response time constraints, strict deadlines, and processed data) and storing the final data in memory (Ram/ Rom).

Software is controlled or initiated by a machine interface. The embedded software is inbuilt in all electronics like cars, telephones, robots, security systems, etc which is simple to run on an 8-bit microcontroller using memory up to a few KB. It helps in processing complex operations and determines the accurate computation framework.

Embedded System Programming Languages

Embedded software uses an operating system, which is a real-time operating system that performs multiple tasks at a time. The embedded programs are programmed using in C / C++, Phyton, and Java Scripts languages and are processed on operating systems like Linux OS, VxWorks, Fusion RTOS, Nucleus RTOS, micro C/OS, OSE, etc. Selection of programming language plays a vital role in developing embedded software, which is based on certain factors as shown below,

  • Size: The amount of memory required by a program plays an important role, as embedded processors (microcontrollers) has a specific amount of ROM (Read Only Memory) based on its application.
  • Speed: The speed of program execution must be fast
  • Portability: Different processors can be compiled using one program.
  • Implementation is difficult
  • Maintenance is difficult.

Programming of an Embedded System in Assembly Language

Programming of an embedded system in assembly language (input) and converting into the machine-level language (output) using an assembler can be explained using the following example, where we perform the addition of two numerics using two sperate registers and store the result in an output register.

Input

HERE: MOV R0,#01H

MOV #1,#02H

MOV A,R0

ADD A,R1

MOV P0,A

SIMP HERE

Output

Address         Opcode     Operand

0000                   78               01
0002                   79               02
0004                   E8                –
0005                   29                –
0006                   F5              80
0008                   80             00

Assembly code is used for developing efficient code in terms of size and speed. Developing larger code in assembly language becomes difficult which may lead to higher software development cost and the code portability is absent. Hence in order to overcome this disadvantage we use high-level language such as embedded C.

About C, C++, Java and Embedded C

C Programming

C language is a structure-oriented language, developed by Dennis Ritchie. It provides less memory access using the simple compiler and delivers the data efficiently according to machine instructions. They are applicable in wide ranges from embedded systems to supercomputers.

Embedded C

Embedded C is an extension of the C language, which is used for developing an embedded system. The syntax is similar to C language (like the main function, functions declaration, data types declaration, loops, etc). The main difference between embedded C and standard C language are input-output addressing of hardware, fixed-point operations, and processing address spaces.

The use of C in the embedded system due to the following advantages

  • It is small and easy to learn, understand and debug the program.
  • All the C compilers are compatible with all embedded devices
  • It is a processor independent (that is, it is not specific to a particular microprocessor or microcontroller).
  • C language uses the combination of assembly language and features of the high-level language
  • It is fairly efficient, more reliable, more flexible, more portable between different platforms.
  • The programs developed in C are easier to understand, debug and maintain.

Compare to other high-level language C offers more flexibility because it is relatively small structure-oriented language and supports low-level bitwise data manipulations.

C++

Object-oriented language like C++ is not optional for developing an efficient program in research constraint environments like embedded devices. Virtual functions and exception handling of C++ are some specific features that are not efficient in terms of space and speed of the system.

JAVA

An embedded system can be programmed in JAVA language, using JAVA virtual machine (JVM) which accesses lots of resources. It primarily finds usage in high-end applications (like mobile phones) and offers portability across systems to process the applications.  It is not preferred for smaller embedded devices.

Embedded C Programming Architecture and Example

Embedded C programming architecture can be understood with an example of using 8051 micro-controllers, where its function is to blink the LED bulb which is connected to PORT1 of the controller and the compiler used is Keil C Compiler. The following is the code for the LED blink.

#include<reg51.h>            // directive of pre-processor
Void delay (int)                //declaration of delay function
Void main(void)             // Main function
{
P1 = 0x00;                    // port1 is off so LED is off and stored in reg51.h
while(1)                       // loop of infinity
{
P1 =OxFF;                //// port1 is on so LED is on
delay(1000);           // assigning delay
P1 = 0X00;            // port1 off
delay(1000);
}
}
Void delay (int d)  // assigning delay function
{
unsigned int i=0; // variables assigned locally
for (; d>0 ; d-)
{
for (i=250 ; i>0;i–);
for (i=248 ; i>0;i–);
}
}

Advantages

The following are the advantages of Embedded Software

  • Loading of data is faster
  • Cost is low
  • Utilizes less resources.

Disadvantages

The following are the disadvantages of Embedded Software

  • Upgrading is complex
  • Every time resetting is necessary if any problems occur
  • Scalability for small values is difficult.

Applications

The following are the applications of Embedded Software

  • Banking
  • Automobiles
  • Home appliances
  • Car
  • Missiles, etc.

FAQ’s

1). What is an Embedded Software?

An embedded software or embedded system programming is computer software, which is used to control devices by providing instructions.

2). What are the programs used in Embedded system software?

The embedded system software programs are programmed in C or C++, Phyton, and Java Scripts.

3). What is the difference between embedded systems and the normal system?

An embedded system is a combination of hardware and software where it is designed for a specific purpose. The processes are processed sequentially. Whereas a normal processor is an RTO’s real-time OS, it is required where there is a need for parallel execution.

4). What are the different types of Embedded systems?

The Embedded systems are classified into two categories

  • Based on performance and functional requirements, they are further classified as Real-time, stand-alone, networked, mobile.
  • Based on the performance of the microcontroller, they are further classified as small scale, medium scale, and sophisticated scale

5). Major applications of embedded system

The major applications of an embedded system are

  • Washing machine
  • Digital cameras
  • Music player, etc.

An embedded system is a combination of hardware and software. Where the embedded software programs are programmed in C or C++, Phyton, and Java Scripts. They run on Linux OS, micro C/OS, QNX, etc. C language forms the basic language for writing embedded software codes. Thus this is an overview of an Embedded Software and its architecture explained using a program.

Add Comment