Infinite Loop

Infinite Loop

Posted on

  • Normally, the program those written for other computer platform will never terminate with the infinite loop, but the program written for the embedded system should be terminated by the infinite loop most of the time.
  • In above example we used while (1) for the infinite loop as it required because in embedded software job is never done without infinite loop.
  • So, the functional part of an embedded program is always surrounded by infinite loops.
  • For example, the output of any sensor need to poll continuously or blinking or LED is required t provide status of something, in such cases infinite loop is required.
  • The Role of the Infinite Loop

One of the most fundamental differences between programs developed for embedded systems and those written for other computer platforms is that the embedded programs almost always end with an infinite loop. Typically, this loop surrounds a significant part of the program’s functionality-as it does in the Blinking LED program. The infinite loop is necessary because the embedded software’s job is never done. It is intended to be run until either the world comes to an end or the board is reset, whichever happens first. In addition, most embedded systems have only one piece of software running on them. And although the hardware is important, it is nota digital watch or a cellular phone or a microwave oven without that embedded software. If the software stops running, the hardware is rendered useless. So the functional parts of an embedded program are almost always surrounded by an infinite loop that ensures that they will run forever.

This behavior is so common that it’s almost not worth mentioning. And I wouldn’t, except that I’ve seen quite a few first-time embedded programmers get confused by this subtle difference. So if your first program appears to run, but instead of blinking the LED simply changes its state once, it could be that you forgot to wrap the calls to Toggle Led and delay in an infinite loop


Embedded software development process:


Steps involved in preparing software for the execution on an embedded system.


The Build Process

  • There are a lot of things that software development tools can do automatically when the target Platform is well defined.This automation is possible because the tools can exploit features of the hardware and operating system on which your program will execute. For example, if all of your programs will be executed on IBM-compatible PCs running DOS, your compiler can automate-and, therefore, hide from your view-certain aspects of the software build process. Embedded software Development tools, on the other hand, can rarely make assumptions about the target platform. Instead, the user must provide some of his own knowledge of the system to the tools by giving them more explicit instructions.The process of converting the source code representation of your embedded software into an executable binary image involves three distinct steps. First, each of the source files must be compiled or assembled into an object file. Second, all of the object files that result from the first step must be linked together to produce a single object file, called the relocatable  program. Finally, physical memory addresses must be assigned to the relative offsets within the relocatable  program in a process called relocation. The resultof this third step is a file that contains an executable binary image that isready to be run on the embedded system. The embedded software development process just described is illustrated in this figure, the three steps are shown from top to bottom, with the tools that perform them shown in boxes that have rounded corners. Each of these development tools takes one or more files as input and produces a single output file. More specific information about these tools and the files they produce is provided in the sections that follow.


  • There are lots of software developments tools can do automatically when the target platform is well defined.
  • The process of converting the source code representation of out embedded software into an executable binary i.e. HEX code file.
  • First of all, the source file must be compiled or assembled into an object file. Then all the object files called as re located program must be linked together to produces single object files.
  • Finally make an executable file that is ready to run on the embedded system.
  • Application program are typically developed, compiled and run the host system.
  • Embedded programs are targeted to a target processor that drives a device on controls.
  • What tools are needed to develop, test, and locate embedded software into the target processor and its operating environment?
  • Host: where the embedded software is developed complied, tested debugged, optimized, and prior to its translation into target devices.
  • Target: after development, the code is cross compiled, translated –cross- assembled, Linked and located into the target.

Compiling the embedded program:

  • A compiler is a program or set of programs that translates source code written in a programming language into another computer language.
  • The most common reason for wanting to transform source code is to create an executable program.
  • The name compiler is primarily used for program that translates sources code from a high level programming language to a lower level language
  • If the compiled program can run on a computer whose cpu or OS is different from the one which the compiler runs, the compiler is known as a cross compiler.


Linking and locating of the embedded program:

  • When an assembly source file is assembled by an assembler and a c source is compiled by a c compiler those two objects files can be linked together by a linker to form the final executable.
  • The assembly files can write using any syntax and assembler that the programmer is comfortable with.
  • Also if changes need to be made in the assembly code all of that code exists in a separate file, that the programmer can easily access.


Locator: produces target machine code and the combined code gets copied into the target ROM.

  • The locator doesn’t stays in the target environment; hence all addresses are resolved guided by locating tools and directives, prior to running the code.



Downloading and debugging of embedded program:

  • During the development phase, most of the times you compile code with debug information enabled.
  • The size of the output files usually quite large but this is acceptable.
  • A different approach is to create multiple files, one built without debug information or stripped and at least one other file containing all symbols information.

Question Bank for Unit 1,2& 3.

Unit 1:

1)      Difference between embedded system and general purpose operating system.

2)      Classification of embedded system.

3)      Explain core of embedded system.

4)      Explain embedded firmware.


Unit 2:

1)      Explain charcterstics of embedded system.

2)      Explain operation and non operational Quality attributes of embedded system.

3)      Explain any of the appliaction of embedded system.


Unit 3:

1)      Explain structure of embedded program with the help of program.

2)      Role of infinite looping.

3)      Explian embedded softeware development process.

4)      Use of compiler.

5)      What do you mean by linking and locating.

Posted By-: Vissicomp Technology Pvt. Ltd.

Website -: