Documente Academic
Documente Profesional
Documente Cultură
CERTIFICATE
This is to certify that the internship report entitled Embedded Systems carried out by
Greeshma Gopal A, USN:1AM15EC043, at Tekatron IT Solutions, a bonafide student of AMC
Engineering College, Bangalore, in partial fulfillment for the award of degree of Bachelor of
Engineering in Electronics and Communication Engineering, of the Visvesvaraya
Technological University, Belgavi during the Year 2018-19. It is certified that all the
corrections/suggestions indicated for internal assessment have been incorporated in the report. The
internship report has been approved as it satisfies the academic requirements in respect of
prescribed for the said degree.
Designated Partners of Tekatron It Solutions Llp are Chethan Chikbilthi Revaiah and
Hamsa Ashwathnarayana.
Registered address:
# 209, 4th Cross Road Near Raghavendra Temple,
Srinivasa Colony,
Bangalore- 560061.
ACKNOWLEDGEMENT
I sincerely thank Dr. N.V. Uma Reddy, HOD, Dept. of Electronics and Communication
Engineering, AMC Engineering College, Bangalore, from the bottom of my heart for her support
and understanding.
I would like to thank our Principal, Dr. A.G.Nataraj, AMC Engineering College,
Bangalore, for his kind cooperation.
My deepest gratitude goes to my teachers, who showed infinite patience and understanding
till the completion of my Internship.
Last, but not the least, my sincere credit to my parents, my friends and to one and all who
have directly or indirectly helped me in the successful completion of the Internship.
GREESHMA GOPAL A
(1AM15EC043)
DECLARATION
I hereby declare that the Internship report entitled “EMBEDDED SYSTEMS” has been
carried out by me under the guidance of my guide, Mrs. Aruna Ramalingam, Associate Professor,
Dept. Of Electronics and Communication Engineering, AMC Engineering College, Bangalore and
submitted in partial fulfillment of the course requirements for the award of the degree in Bachelor
of Electronics and Communication Engineering during the year 2018-19.
The matter embodied in this report has not been submitted to any other university or institution
for the award of any other degree or diploma.
GREESHMA GOPAL A
(1AM15EC043)
EMBEDDED SYSTEMS
LIST OF CONTENTS
CHAPTER CHAPTER NAME PAGE
No. NO.
1. INTRODUCTION TO EMBEDDED SYSTEMS
1.1 SYSTEM 1
1.2 EMBEDDED SYSTEM 1
2. CHARACTERISTICS OF AN EMBEDDED SYSTEM, ITS
ADVANTAGES AND DISADVANTAGES
2.1 CHARACTERISTICS OF AN EMBEDDED SYSTEM 3
2.2 ADVANTAGES AND DISADVANTAGES OF AN EMBEDDED 4
SYSTEM
3. BASIC STRUCTURE OF AN EMBEDDED SYSTEM 5
4. PROCESSORS
4.1 PROCESSORS IN A SYSTEM 6
4.2 TYPES OF PROCESSORS 6
4.3 MICROPROCESSOR VS MICRCONTROLLER 8
4.4 VON NEUMANN ARCHITECTURE 9
4.5 HARVARD ARCHITECTURE 10
4.6 VON-NEUMAN VS HARVARD ARCHITECTURE 11
4.7 CISC AND RISC 11
5. CLASSIFICATIONS OF EMBEDDED SYSTEM
5.1 SMALL SCALE EMBEDDED SYSTEMS 13
5.2 MEDIUM SCALE EMBEDDED SYSTEMS 13
5.3 SOPHISTICATED EMBEDDED SYSTEMS 14
6. MOORE’S LAW 15
7. 7.1 PROGRAM
7.2 MACHINE LANGUAGE 16
7.3 ASSEMBLY LANGUAGE 16
8. C PROGRAM 18
8.1 C PROGRAM STRUCTURE 19
8.2 C PROGRAM DIRECTIVES 20
8.3 IDENTIFIERS 20
8.4 KEYWORDS 21
8.5 STATEMENTS 22
8.6 PRE-PROCESSOR DIRECTIVES 23
8.7 C FUNCTION 25
9. COMPILERS
9.1 THE PREPROCESSOR 30
9.2 THE COMPILER 30
9.3 THE LINKER 31
10. CROSS DEVELOPMENT
10.1 CROSS COMPILER 32
10.2 CROSS DEVELOPMENT TOOLS 33
11. PROBLEMS FACED 34
12. TROUBLE SHOOTING OF PROBLEMS 35
13. SUMMARY 36
LIST OF FIGURES
FIGURE FIGURE NAME PAGE
NO. NO.
LIST OF TABLES
TABLE TABLE NAME PAGE
NO. NO.
CHAPTER 1
INTRODUCTION TO EMBEDDED SYSTEMS
1.1 System
A system is an arrangement in which all its unit assemble work together according to a set
of rules. It can also be defined as a way of working, organizing or doing one or many tasks
according to a fixed plan. For example, a watch is a time displaying system. Its components follow
a set of rules to show time. If one of its parts fails, the watch will stop working. So we can say, in
a system, all its subcomponents depend on each other.
As its name suggests, Embedded means something that is attached to another thing. An
embedded system can be thought of as a computer hardware system having software embedded in
it. An embedded system can be an independent system or it can be a part of a large system. The
block diagram of an embedded system is given in Fig.1.1. An embedded system is a
microcontroller or microprocessor based system which is designed to perform a specific task. For
example, a fire alarm is an embedded system; it will sense only smoke.
• It has hardware.
• It has application software.
• It has Real Time Operating system (RTOS) that supervises the application software
and provide mechanism to let the processor run a process as per scheduling by
following a plan to control the latencies. RTOS defines the way the system works. It
sets the rules during the execution of application program. A small scale embedded
system may not have RTOS.
So we can define an embedded system as a Microcontroller based, software driven,
reliable, real-time control system.
CHAPTER 2
CHARACTERISTICS OF AN EMBEDDED SYSTEM, ITS
ADVANTAGES AND DISADVANTAGES
2.1.2 Tightly constrained – All computing systems have constraints on design metrics,
but those on an embedded system can be especially tight. Design metrics is a measure of an
implementation's features such as its cost, size, power, and performance. It must be of a
size to fit on a single chip, must perform fast enough to process data in real time and
consume minimum power to extend battery life.
2.1.3 Reactive and Real time – Many embedded systems must continually react to
changes in the system's environment and must compute certain results in real time without
any delay. Consider an example of a car cruise controller; it continually monitors and reacts
to speed and brake sensors. It must compute acceleration or de- accelerations repeatedly
within a limited time; a delayed computation can result in failure to control of the car.
2.1.5 Memory – It must have a memory, as its software usually embeds in ROM. It does
not need any secondary memories in the computer.
2.1.6 Connected – It must have connected peripherals to connect input and output
devices.
2.1.7 HW-SW systems – Software is used for more features and flexibility. Hardware
is used for performance and security.
2.2.1 Advantages
• Easily Customizable
• Low power consumption
• Low cost
• Enhanced performance
2.2.2 Disadvantages
CHAPTER 3
BASIC STRUCTURE OF AN EMBEDDED SYSTEM
3.1 Sensor – It measures the physical quantity and converts it to an electrical signal which
can be read by an observer or by any electronic instrument like an A2D converter. A sensor
stores the measured quantity to the memory.
3.2 A-D Converter – An analog-to-digital converter converts the analog signal sent by the
sensor into a digital signal.
3.3 Processor & ASICs – Processors process the data to measure the output and store it to
the memory.
3.4 D-A Converter – A digital-to-analog converter converts the digital data fed by the
processor to analog data.
3.5 Actuator – An actuator compares the output given by the D-A Converter to the actual
(expected) output stored in it and stores the approved output.
CHAPTER 4
PROCESSORS
Processor is the heart of an embedded system. It is the basic unit that takes inputs and
produces an output after processing the data. For an embedded system designer, it is necessary
to have the knowledge of both microprocessors and microcontrollers.
The CU includes a fetch unit for fetching instructions from the memory. The EU has
circuits that implement the instructions pertaining to data transfer operation and data
conversion from one form to another.
The EU includes the Arithmetic and Logical Unit (ALU) and also the circuits that
execute instructions for a program control task such as interrupt, or jump to another set of
instructions.
A processor runs the cycles of fetch and executes the instructions in the same sequence
as they are fetched from memory.
• Embedded Processor
• Digital Signal Processor
• Media Processor
• Application Specific System Processor (ASSP)
• Application Specific Instruction Processors (ASIPs)
• GPP core(s) or ASIP core(s) on either an Application Specific Integrated Circuit
(ASIC) or a Very Large Scale Integration (VLSI) circuit.
4.2.1 Microprocessor
A microprocessor is a single VLSI chip having a CPU. In addition, it may also have
other units such as coaches, floating point processing arithmetic unit, and pipelining units that
help in faster processing of instructions. Fig. 4.1 shows a simple block diagram of a
Microprocessor.
Earlier generation microprocessors’ fetch-and-execute cycle was guided by a clock
frequency of order of ~1 MHz. Processors now operate at a clock frequency of 2GHz.
4.2.2 Microcontroller
External support of external memory and I/O Microcontrollers are lightweight and cheaper than
ports makes a microprocessor-based system a microprocessor.
heavier and costlier.
External devices require more space and their A microcontroller-based system consumes less
power consumption is higher. power and takes less space.
The 8051 microcontrollers work with 8-bit data bus. So they can support external data
memory up to 64K and external program memory of 64k at best. Collectively, 8051
microcontrollers can address 128k of external memory.
When data and code lie in different memory blocks, then the architecture is referred as
Harvard architecture. In case data and code lie in the same memory block, then the architecture
is referred as Von Neumann architecture.
sequential memory. Today's processing speeds vastly outpace memory access times, and we
employ a very fast but small amount of memory (cache) local to the processor.
The following points distinguish the Von Neumann Architecture from the Harvard
Architecture.
Table 4.3 Von- Neumann Vs Harvard Architecture
Single memory to be shared by both code and data. Separate memories for code and data.
Processor needs to fetch code in a separate clock cycle and Single clock cycle is sufficient, as separate
data in another clock cycle. So it requires two clock buses are used to access code and data.
cycles.
Higher speed, thus less time consuming. Slower in speed, thus more time-consuming.
Simple in design. Complex in design.
CISC is a Complex Instruction Set Computer. It is a computer that can address a large
number of instructions.
In the early 1980s, computer designers recommended that computers should use fewer
instructions with simple constructs so that they can be executed much faster within the CPU
without having to use memory. Such computers are classified as Reduced Instruction Set
Computer or RISC.
CISC RISC
CHAPTER 5
CLASSIFICATIONS OF EMBEDDED SYSTEM
• Small Scale Embedded System
• Medium Scale Embedded System
• Sophisticated Embedded System
5.1 Small Scale Embedded Systems
These systems are designed with a single 8- or 15-bit microcontroller; they have little
hardware and software complexities and involve board level design. Example for small
scale embedded system is given in Fig. 5.1.They may even be battery operated. When
developing embedded software for these, an editor, assembler and cross assembler,
specific to the microcontroller or processor used, are the main programming tools.
Usually, ‗C‘ is used for developing these systems. ‗C‘ program compilation is done
into the assembly, and executable codes are then appropriately located in the system
memory. The software has to fit within the memory available and keep in view the need
to limit power dissipation when system is running continuously.
These systems are usually designed with a single or few 16- or 32-bit
microcontrollers or DSPs or Reduced Instruction Set Computers (RISCs). These have
both hardware and software complexities. Example for small scale embedded system is
given in Fig. 5.2. For complex software design, there are the following programming
tools: RTOS, Source code engineering tool, Simulator, Debugger and Integrated
Development Environment (IDE). Software tools also provide the solutions to the
hardware complexities. An assembler is of little use as a programming tool. These
systems may also employ the readily available ASSPs and IPs (explained later) for the
CHAPTER 6
MOORE’S LAW
Moore's law describes a long-term trend in the history of computing hardware. Since
the invention of the integrated circuit in 1958, the number of transistors that can be placed
inexpensively on an integrated circuit has increased exponentially, doubling approximately
every two years. Refer Fig. 6.1 and Fig.6.2. The trend was first observed by Intel co-founder
Gordon E. Moore in 1965. Almost every measure of the capabilities of digital electronic
devices is linked to Moore's law: processing speed, memory capacity, etc.
CHAPTER 7
PROGRAM
The most important thing to remember about computers is that they can do only what they
are instructed to do. To accomplish a meaningful task on a computer, someone must give it
exhaustive and very explicit instructions. A collection of such instructions is a called a program
and the person who writes and revises these instructions is known as a programmer or
developer.
Each microcontroller has its own assembly language or assembly language variation.
Assembly language consists of mnemonic instructions and addressing modes where the
instruction describes what to do and the addressing mode describes where to do it. Table 7.1
gives the Instructions from the National Semiconductor COP888 assembly language.
Table 7.1 Instructions from the National Semiconductor COP888 assembly language
8 bit microcontrollers usually use byte size instruction codes. Each instruction
has two possible components: an opcode and an operand. The opcode is the function
that the instruction performs while the operand is data used by the opcode. Neither
opcodes nor operands are restricted to 1 byte. There are several different types of
addressing modes. An addressing mode is simply the means by which an address is
determined. Some common modes are immediate data, direct address, and indirect or
indexed address.
CHAPTER 9
C PROGRAM
A C program can vary from 3 lines to millions of lines and it should be written into one
or more text files with extension ".c"; for example, hello.c. You can use "vi", "vim" or
any other text editor to write your C program into a file.
Traditionally, the first program a developer writes in the C language is one which
displays the message Hello World! on the computer screen. This is a sensible beginning for
traditional C platforms where conventional input and output are important and fundamental
concepts.
Let us look at a simple code that would print the words "Hello World":
#include <stdio.h>
int main()
/* my first program in C */
printf("Hello, World! \n");
return 0;
}
Let us take a look at the various parts of the above program:
The first line of the program #include <stdio.h> is a preprocessor command, which tells a
C compiler to include stdio.h file before going to actual compilation.
The next line int main() is the main function where the program execution begins.
The next line /*...*/ will be ignored by the compiler and it has been put to add additional
comments in the program. So such lines are called comments in the program.
The next line printf(...) is another function available in C which causes the message "Hello,
World!" to be displayed on the screen.
The next line return 0; terminates the main() function and returns the value 0.
In the world of 8 bit microcontrollers device input and output play radically different roles.
Programs rarely have access to keyboard input or screen output devices which are common in
traditional C programming.
In Example shown in Figure 9.1, the compiler is informed that two ports are available.
The name PortA refers to physical port A’s data register, which is available for reading and
writing and is located at address 0x0A. The name PortADir refers to physical port A’s data
direction register, which is available for writing only and is located at address 0x8A.
The condition is the integer 1b (binary), which is interpreted as true. Therefore, once
the computer begins to execute statements inside the braces of the while loop, it will not
terminate until the computer malfunctions or is turned off. This kind of loop is often called an
infinite loop. In traditional C programming, an infinite loop is usually avoided. However, it is
often used in embedded systems programming. An embedded controller typically executes a
single program “infinitely”. Only when the controller is reset or turned off will the loop
terminate.
• 2. Declarations are instructions for the compiler to record the type and
associated memory locations of symbols
• 3. Statements are the executable instructions in a program.
The simple C program shown in Example 6 in the previous section introduced several
preprocessor directives: #include directives include the contents of another file, #define
directives define symbolic constants, #pragma directives describe details of the target
hardware.
8.3 Identifiers
8.3.1 Declaration
For example, you can write instructions to add together two numbers
without knowing the values of the numbers. This can be done through the use
of identifiers.
The C language has keywords which the compiler reserves because they
have special meaning in the language. For example, the word “ if” is used to
signify the beginning of a decision block.
8.4 Keywords
A keyword may not be used as an identifier name. Table 8.1 gives a list of the reserved words
in C.
8.5 Statements
currentTemperature = 20;
The compiler will generate an instruction to store the value 20 in the RAM memory
location set aside for the currentTemperature variable.
currentTemperature = 20
currentTemperature = 25;
The compiler would produce an error. Forgetting the semicolon at the end of
the first line forces the compiler to read both lines as one statement instead of two.
According to the compiler the written instruction is:
The C compiler does not care about white space between tokens as it reads
through the program. White space includes space, tab and end-of-line characters. On
some computers the end of line will be a single linefeed character, while on others it
will be a linefeed and carriage return together. C compilers ignore both carriage returns
and linefeeds.
8.6.1 #include
#include is one of the most commonly used preprocessor directives. When the
preprocessor reaches this directive it looks for the file named in the brackets. In the
example above the preprocessor searches for the file hc705c8.h which contains device
specific specifications for the Motorola 68HC705C8. If the file is found the
preprocessor will replace the #include directive with the entire contents of the file. If
the file is not found the preprocessor will halt and give an error. In the example the
#include directive is used to include the contents of a header file. By convention, C
language header files have the .h extension. Header files contain information which is
used by several different sections, or modules, of a C program as they contain
preprocessor directives and predefined values which help to describe the resources and
capabilities of a specific target microcontroller. #define ON 1 #define OFF 0 #define is
another commonly used preprocessor directive which is used to define symbolic
constants. Programs often use a constant number or value many times. Instead of typing
in the actual number or value throughout the program, one can define a symbol which
represents the value. When the preprocessor reaches a #define directive, it will replace
all the occurrences of the symbol name in your program with the associated constant.
8.6.2 #pragma
8.7 C Functions
C programs are built from functions. Functions typically accept data as input,
manipulate data and return the resulting value. For example, we can write a C function that
would take two numbers, add them together and return the sum as the result.
All C programs must have one function called main()which is always the first
function executed. A function name is specified by following the name with
parentheses. This is the notation used by the C compiler to determine when it has
encountered a function. As long as the name is not a recognised C command, called a
reserved word, the compiler will assume it is a function if it is immediately followed
by a pair of parentheses. The parentheses may also surround a list of input arguments
for the function.
void main(void)
{ //function statements
The first use of the term void, prior to the word main, indicates to the compiler
that this main() function does not return any value at all. The second use of the term
void, between the parentheses, indicates to the compiler that this main() function is not
sent any data in the form of arguments. Braces must surround all statements which form
the body of a function. Even functions with no statements in their body require the
braces – the braces after a function header indicate to the compiler that you are
providing the definition of a function.
The main() function can execute code from other functions. This is referred to
as calling another function. The calling function must know about the called function
in order to execute its code.
void wait(registera);
The example above is a function prototype for a function called wait(). This
function is preceded by the return value void; therefore, it does not return a value.
Unlike main(), the wait() function does expect to receive an argument, called a
parameter. The type of the parameter (registera) is type registera.
PortADir.1 = INPUT;
represents the port A direction register. From the #define directives we know
that OUTPUT is really a symbolic constant associated with the value 0.
Therefore, this assignment statement clears bit 0 of the port A direction register.
By contrast, the second assignment statement sets bit 1 of the port A direction
register as INPUT is a symbolic constant associated with the value 1 in a #define
statement.
while(1)
// statements
The if() statement provides the ability to make decisions. If the if statement
condition is true then the computer executes the statements in the if body. In Example
9, the value of PortA.1 is compared with the value of PUSHED, if data bit number 1 is
set (has the value 1) then the program will execute any statements in the if body. The
body statement sets port A data bit number 0 by assigning it the value of ON.
while (1)
if (PortA.1 == PUSHED)
PortA.0 = ON;
When the if decision is placed inside a while loop, the program will test bit 1 in
PortA regularly. Assume a button is attached to pin 1 of port A and an LED to pin 0 of
PortA. We have written a small control program which will continually test the button
attached to pin 1. When the button is pushed, bit 1 of PortA will be set. When bit 1 is
set and the if statement is executed, bit 0 is set. The LED attached to PortA pin 0 will
be set to 1 and will light up.
A program can delegate a task by calling another function. Once the program
turns on the LED in Example 10 it never turns it off. Remember, the while loop is an
infinite loop. How can we solve this problem? One solution is to write a function called
wait()which creates a delay and then turn the LED off.
while (1)
if (PortA.1 = PUSHED)
{ PortA.0 = ON;
PortA.0 = OFF;
}}
When the wait() function is used and the button is pushed, the program turns
the LED on by setting bit 0 of PortA. The wait() function causes a delay of ten seconds.
After the wait function has finished and ten seconds have passed, the program turns off
the LED by clearing bit 0 of PortA.
CHAPTER 9
COMPILERS
Compilers translate high level programming language instructions into machine
language. They perform the same task for high level languages that an assembler performs for
assembly language, translating program instructions from a language such as C to an equivalent
set of instructions in machine language.
This translation does not happen in a single step – three different components are
responsible for changing C instructions into their machine language equivalents. These three
components are:
• Preprocessor
• Compiler
• Linker
When programs were written in the past often the development computer was
not powerful enough to hold the entire program being developed in memory at one
time. Historically, programs had to be divided into separate modules where each
module would be compiled into object code and a linker would link the and the use of
a linker is no longer absolutely necessary. Many implementations of C provide function
libraries which have been precompiled for a particular computer. These functions serve
common program needs such as serial port support, input/output, and description of the
destination computer. Functions within libraries are usually either linked with modules
which use them or included directly by the compiler if the compiler supports library
function inclusion. When a program has been pre-processed, compiled and linked, the
destination computer will be able to read and execute your program.
CHAPTER 11
CROSS DEVELOPMENT
A cross compiler runs on one type of computer and produces machine code for a
different type of computer. While many 8 bit embedded microcontrollers can support
sophisticated and extremely useful programs, they are not powerful enough to support the
resource needs of a C development environment. A developer creates and compiles programs
for an 8 bit microcontroller using a cross compiler.
10.2.1 Simulator
simulator has all the functionality of the software simulator while also supporting the
emulation of the microcontroller’s I/O capabilities.
10.2.2 Emulator
CHAPTER 11
PROBLEMS FACED
1. It was the first experience of job and thus, the main problem that I faced was
impunctuality. In a professional workspace, impunctuality isn’t acceptable and hence
managing time was a little difficult for me initially.
CHAPTER 12
TROUBLESHOOTING OF PROBLEMS
1. Self-management wasn’t something that I could learn overnight. I achieved it only
through habit forming and by adopting a more organized living and started going to my
Internship on time.
2. Keen on learning the new topics, and getting to know about the intern-friendly
environment there, I started asking my queries without the worry of being judged. The
appreciation that I got on clarifying my doubts also motivated me in asking further
queries and getting them clarified.
CHAPTER 13
SUMMARY
The Internship on Embedded Systems included the following –