Unit-III Ies Part2
Unit-III Ies Part2
and Programming
What Are Embedded Systems?
“Special purpose system which are either used as standalone or part of a
big system”
Ce l l ul a r telephones
E n g i n e controllers
in automobiles
Calculators
Medical
equipment’s
The necessary tools for a
microprocessor/microcontroller
CPU: Central Processing Unti
I/O: Input /Output
Bus: Address bus & Data bus
Memory: RAM & ROM
Timer
Interrupt
Introduction to Microprocessors
“A Microprocessor is a general purpose chip used to create multifunction
device ”
Microcontroller Microprocessor
• CPU, RAM, ROM, I/O and • CPU is stand-alone,
timer are all on a single chip RAM, ROM, I/O, timer are
separate
• Fix amount of on-chip ROM,
•
RAM, I/O ports
Designer can decide the amount
• For applications in which cost, of ROM, RAM and I/O ports
power and space are critical •
Expansive
• Not Expansive •
Versatility
• Single-purpose •
General-
Criteria for Choosing a Microcontroller
Following must be kept in mind while choosing a
Speed
microcontroller
Packaging
Power consumption
The amount of RAM and ROM on chip
The number of I/O pins and the timer on chip
How easy to upgrade to higher performance or lower power-
consumption versions
Cost per unit
Microcontroller Architectures
Memory
Address Bus 0
Program
CPU Data Bus + Data Von Neumann
Architecture
2n
Memory
Address Bus 0
Program
CPU
Fetch Bus Harvard
Address Bus 0
Architecture
Data Bus Data
Features Of 8051
The Intel 8051 is used in embedded systems has
8-bit CPU
2 timers
6 interrupt sources
•Port 0: Port 0 occupies a total of 8 pins (pins 32-39) .It can be used for input or
output. To use the pins of port 0 as both input and output ports, each pin must be
connected externally to a 10K ohm pull-up resistor.
•Port 1: Port 1 occupies a total of 8 pins (pins 1-8). It can be used as input or
output. In contrast to port 0, this port does not need any pull-up resistors since it
already has pull-up resistors internally.
•Port 2 : Port 2 occupies a total of 8 pins (pins 21- 28). It can be used as input or
output. Just like P1, P2 does not need any pull-up resistors since it already has
pull-up resistors internally.
•Port 3 : Port 3 occupies a total of 8 pins (pins 10 -17). It can be used as input or
output. P3 does not need any pull-up resistors, the same as P1 and P2 did not.
Port 3 has the additional function of providing some extremely important signals
such as interrupts, etc.
IMPORTANT
PINS
VCC (Pin-40): Vcc provides supply voltage to the chip. The
voltage source is +5V.
GND (Pin-20): It is ground pin.
RST (Pin-9): It is reset pin. Upon applying high pulse to thsi pin
the micro controller will reset and terminate all activities.
XTAL1 & XTAL2 (Pin-18,19): These 2 pins provide external
clock using a quartz crystal oscillator Crystal inputs for
internal oscillator.
PSEN (Pin-29): Program Store Enable, the read signal
for external program memory.
IMPORTANT PINS
Features
• Both Timer T0 and T1 are 16 bits wide.
• When used as a “timer” the register is programmed to count
internal clock pulses
• When used as a “counter” the register is programmed to
count external clock pulses
INTERRUPT
Interrupt is an event that causes program to change its
normal execution and branch up to specific subroutine
putting normal program on hold.
every embedded system we come across in our daily life, such as mobile
1
8
Each processor is associated with an embedded software.
the microcontroller.
1
9
Earlier, many embedded applications were developed using assembly level
languages like C, Pascal, and COBOL. However, it was the C language that
The C code written is more reliable, scalable, and portable; and in fact,
2
0
About C
Language
•C language was developed by Dennis Ritchie in 1969.
5
Salient features of the language
The embedded system designers must know about the hardware architecture to write programs.
These programs play prominent role in monitoring and controlling external devices. They also
directly operate and use the internal architecture of the microcontroller, such as interrupt
handling, timers, serial communication and other available features.
The basic additional features of the embedded
software
Data types
The embedded C software uses four data types that are used to store
data in the memory.
The ‘char’ is used to store any single character; ‘int’ is used to store
integer value, and ‘float’ is used to store any precision floating point
value.
The size and range of different data types on a 32-bit machine is given in
the following table. The size and range may vary on machines with
Keyword
s
There are certain words that are reserved for doing specific tasks. These
program.
SFR Register:
This RAM is divided into two parts: the first part of 128 bytes
is used for data storage, and the other of 128 bytes is used
for SFR registers.
…………..
}
fun(1)
{
local variables
statements
…………..
Comments:
Preprocessor directives: