Вы находитесь на странице: 1из 85

Department of ELECTRONICS & COMMUNICATION

Engineering

JCD College of Engineering, Sirsa

A
SUMMER TRAINING REPORT
ON

EMBEDDED SYSTEM
SUBMITTED TO: Mr. Vinod Kumar

SUBMITTED BY:Diksha,Sangam,Priyanka

ELECTRONICS
Electronics is the branch of science which deals with the
behavior of electron under the influence of electric and
magnetic field.
Started with development of telegraph in late 19th century.
Applications:
Radio
Television
RADAR
Computer

TYPES OF ELECTRONIC CIRCUIT


Analog circuit.
They use a continuous range of voltage.
Digital Circuit.
They are based on a number of discrete voltage levels.

EMBEDDED SYSTEM
An embedded system is one that has a dedicated
purpose software embedded in a computer
hardware.

It processes a fixed set of pre-programmed


instructions to control electromechanical equipment
which may be part of an even larger system

DIFFERENCE BETWEEN PERSONAL


COMPUTER AND EMBEEDED SYSTEM
PERSONAL COMPUTER EMBEDDED SYSTEM
General purpose system

Single purpose

Always having a user


interface
Slow in operation

Less or no user interface

Larger in size

Smaller in size

Power consuming

Requires less power

Faster than pc

TYPICAL EMBEDDED SYSTEM

CHARACTERISTICS OF EMBEDDED SYSTEMS


Embedded systems are application specific & single
functioned.
Efficiency is of paramount importance for embedded
systems
Embedded systems often interact (sense, manipulate &
communicate) with external world through sensors and
actuators
They generally have minimal or no user interface.

EMBEDDED SYSTEM DESIGN


Requirement analysis.
Defining the system specifications.
Modeling the system to be designed.
HW-SW partitioning.
Selection of technology.
Resource Analysis Cost, Time & Manpower.
Identification of components and development
tools.
Circuit design/ Schematic Capture, PCB layout
design & fabrication.
testing.
System Integration.
Testing functional, environmental

ELECTRONIC COMPONENTS

Resistor
Capacitor
Diode
Switches
LED
Seven segment display
LCD
Relay

RESISTOR
It is a electrical component that
limits the flow of electric current in
the circuit.
Tendency to oppose electric
current.
Resistor is a passive component
used to control current in a circuit.
The resistance is given by the ratio
of voltage applied across the
terminals to the current passing
through it.

CAPACITOR
Capacitor is a passive component used to
store charge.
The charge (q) stored in a capacitor is the
product of its capacitance (C) value and the
voltage (V) applied to it.
Q=C*V
It stores electric charge and then discharges
it into the circuit.
It blocks the direct current and allows the
alternating current to pass through it.
The unit of capacitance is FARAD.
A capacitor contains two conductor plates
which are generally made of metal and an
insulator between them.

DIODE
A diode is a unipolar device.
Diode is a rectifying device which conducts
only from anode to cathode.
Diode behaves open circuited for the current
flow from cathode to anode.
When forward biased there is a small amount
of voltage necessary to get the diode going.
When reverse biased an ideal diode will
block current.
If enough voltage (reverse) is applied, and
junction breaks down and lets current pass
through.

SWITCH
Used to make or break electronic circuit.

LED (LIGHT EMMITING DIODE)


Light emitting diodes (LEDs) are semiconductor
light sources.
The light emitted from LEDs varies from visible
to infrared and ultraviolet regions.
They operate on low voltage and power.
They are mostly used as indicators in circuits.
Based on semiconductor diode, LEDs emit
photons when electrons recombine with
holes on forward biasing.

WORKING OF LED

SEVEN SEGMENT DISPLAY


A seven segment display is the most basic
electronic display device that can display
digits from 0-9.
The most common configuration has an
array of eight LEDs arranged in a special
pattern to display these digits.
They are laid out as a squared-off figure
8.
Every LED is assigned a name from 'a' to
'h' and is identified by its name.
LEDs 'a' to 'g' are used to display the
numerals while eighth LED 'h' is used to
display the dot/decimal.

These segments come in two configurations, namely,


Common cathode (CC) and Common anode (CA).
In CC configuration, the negative terminals of all LEDs
are connected to the common pins.
In CA arrangement, the common pin is given a high logic
and the LED pins are given low to display a number.

LCD (LIQUID CRYSTAL DISPLAY)

LCD (Liquid Crystal Display) screen is an


electronic display module.
A 16x2 LCD display is very basic module.
LCDs are economical.
Easily programmable.
A 16x2 LCD means it can display 16
characters per line and there are 2 such
lines.
This LCD has 2 resistors, namely command
and data.
The command resistor stores the command
instructions given to the LCD.
The data resistor stores the data to be
displayed on the LCD.

PIN DIAGRAM OF LCD

DC Motor.
Stepper Motor.
Transistors.
Voltage Regulators.
H-Bridge

A simple device that converts electrical


energy into mechanical energy.

DC motors have a rotating armature winding


(winding in which a voltage is induced) but
Non-rotating armature magnetic field and a
static field winding (winding that produce the
main magnetic flux) or permanent magnet.

A stepper motor (or step motor) is a brushless


DC electric motor that divides a full rotation into
a number of equal steps.
The motor's position can then be commanded
to move and hold at one of these steps without
any feedback sensor.
As all motors, the stepper motors consists of a
stator an a rotor.

To make the motor shaft turn, first, one


electromagnet
is
given
power,
which
magnetically attracts the gear's teeth.
When the gear's teeth are aligned to the first
electromagnet, they are slightly offset from the
next electromagnet.
So when the next electromagnet is turned on
and the first is turned off, the gear rotates slightly
to align with the next one, and from there the
process is repeated.
Each of those rotations is called a "step", with
an integer number of steps making a full rotation.
Types:
Single-coil excitation.
Full step drive.

TRANSISTOR

A transistor, stands for transfer of


resistance.
Transistor, a solid-state device used in
electronic circuits primarily as an amplifier
or switch.
They work something like a water faucet -not only do they start and stop the flow of a
current, but they also control the amount of
the current.
A conventional transistor is enclosed in a
protective casing and has three electrical
leads.

VOLTAGE REGULATOR
A voltage regulator is a device that
maintains a relatively constant
output voltage even though its input
voltage may be highly variable.
The voltage regulator IC maintains
the output voltage at a constant
value.
The 78xx is voltage regulator IC
series.
The xx in 78xx indicates the fixed
output voltage it is designed to
provide.

MICROPROCESSOR
Microcomputer a computer with a microprocessor as its
CPU. Includes memory, I/O etc.
Microprocessor silicon chip which includes ALU,
register circuits & control circuits
Microcontroller silicon chip which includes
microprocessor, memory & I/O in a single package.

The word comes from the combination micro and


processor.
Processor means a device that processes whatever. In
this context processor means a device that processes
numbers, specifically binary numbers, 0s and 1s.
To process means to manipulate. It is a general term
that describes all manipulation. Again in this content, it
means to perform certain operations on the numbers
that depend on the microprocessors design

DEFINITIONS REGARDING
MICROPROCESSOR
Microprocessor: is a programmable device that takes in
numbers, performs on them arithmetic or logical operations
according to the program stored in memory and then
produces other numbers as a result
Instructions: Each microprocessor is designed to execute a
specific group of operations. This group of operations is
called an instruction set. This instruction set defines what the
microprocessor can and cannot do.

Takes in: The data that the microprocessor manipulates


must come from somewhere. It comes from what is called
input devices.
These are devices that bring data into the system from the
outside world such as a keyboard, a mouse
Numbers: The microprocessor has a very narrow view on
life. It only understands binary numbers
Words, Bytes, etc. The earliest microprocessor (the Intel
8088 and Motorolas 6800) recognized 8-bit words. They
processed information 8-bits at a time. Thats why they are
called 8-bit processors.
Later microprocessors (8086 and 68000) were designed
with 16-bit words. A group of 8-bits were referred to as a
half-word or byte.
Today, all processors manipulate at least 32 bits at a time
microprocessors that can process 64, 80, 128 bits

Arithmetic and Logic Operations: Every microprocessor


has arithmetic operations such as add and subtract as part of
its instruction set. Most microprocessors will have
operations such as multiply and divide.
Some of the newer ones will have complex operations such
as square root.
In addition, microprocessors have logic operations as well.
Such as AND, OR, XOR, shift left, shift right, etc.
Stored in memory: When a program is entered into a
computer, it is stored in memory. Then as the
microprocessor starts to execute the instructions, it brings
the instructions from memory one at a time.
Produces: For the user to see the result of the execution of
the program, the results must be presented in a human
readable form

INSIDE THE MICROPROCESSOR


Internally, the microprocessor is made up of 3
main units:
The Arithmetic/Logic Unit (ALU)
The Control Unit.
An array of registers -for holding data while it
is being manipulated.
CPU
GeneralPurpose
Microprocessor

Data Bus

RAM

ROM

Address Bus

I/O
Port

Timer

Serial
COM
Port

A MICROPROCESSOR-BASED SYSTEM

ORGANIZATION OF SYSTEM

INTERNAL ARCHITECTURE

MICROCONTROLLER
A microcontroller is a small and low-cost computer
built for the purpose of dealing with specific tasks, such
as displaying information in a microwave LED or
receiving information from a televisions remote control.
Microcontrollers are mainly used in products that
require a degree of control to be exerted by the user.
Microcontroller is a device which integrates a number of
the components of a microprocessor system onto a single
microchip. So a microcontroller combines onto the same
microchip :
The CPU core
Memory (both ROM and RAM)
Some parallel digital I/O

Criteria in Choosing a Microcontroller


1. Meeting the computing needs of the task efficiently
and cost effectively
Speed, the amount of ROM and RAM, the number of
I/O ports and timers, size, packaging, power
consumption
Cost per unit
2.Availability of software development tools
3.Wide availability and reliable sources of the
microcontrollers.

Introduction to Microcontroller

The microcontroller is a very common component in


modern electronic systems. Its use is so widespread that
it is almost impossible to work in electronics without
coming across it. Microcontroller are used in a wide
number of electronic systems such as:
Engine management systems in automobiles.
Keyboard of a PC.
Electronic measurement instruments (such as digital
multimeters, frequency synthesisers, and oscilloscopes)
Printers,Mobile phones.
Televisions, radios, CD players, tape recording
equipment.

Comparison of 8051 Family Members


Features
ROM
RAM
Timers
I/O pins
Serial port
Interrupt Sources

8051
4K
128
2
32
1
6

8052
8K
256
3
32
1
8

8031
10K
128
2
32
1
6

Features of 8051
ROM
- 4K bytes
RAM
- 128 bytes
Timer
- 2
I/O pins
- 32
Serial port
- 1
Interrupt sources - 6
8051 is based on CISC architecture.
It is based on Harvard architecture. So, it has separate
program and data memory.

APPLICATIONS OF MICROCONTROLLERS

Mobile Phones
Auto Mobiles
Washing Machines
Cameras
Security Alarms

Microprocessor vs Micro-controllers
Microprocessors
High end of market where performance matters
High power dissipationhigh cost
Need peripheral devices to work
Diff programs multiple times
Microcontrollers
Targeted for low end of market where performance does not
matter
Low power dissipation low cost
Memory plus I/O devices, all integrated into one chip
Single program multiple times

TYPES OF MICRO CONTROLLERS

BITS
In 8-bit microcontroller, the point when the internal bus is
8-bit . The examples of 8-bit microcontrollers are Intel
8031/8051, PIC1x and Motorola MC68HC11 families.
The 16-bit microcontroller performs greater precision and
performance as compared to 8-bit. Some examples of 16-bit
microcontroller are 16-bit MCUs are extended 8051XA,
PIC2x, Intel 8096 and Motorola MC68HC12 families.
The 32-bit microcontroller uses the 32-bit instructions to
perform the arithmetic and logic operations. These are used
in automatically controlled devices including engine control
systems, office machines, appliances . Some examples are
Intel/Atmel 251 family, PIC3x.

MEMORY DEVICES
Embedded memory microcontroller: When an embedded
system has a microcontroller unit that has all the
functional blocks available on a chip is called an
embedded microcontroller. For example, 8051 having
program & data memory, I/O ports, serial
communication, counters and timers and interrupts on the
chip is an embedded microcontroller.
External Memory Microcontroller: When an embedded
system has a microcontroller unit that has not all the
functional blocks available on a chip is called an external
memory microcontroller. For example, 8031 has no
program memory on the chip is an external memory
microcontroller.

INSTRUCTION SET
CISC: CISC is a Complex Instruction Set Computer. It
allows the programmer to use one instruction in place of
many simpler instructions.
RISC: The industry trend for microprocessor design is
for Reduced Instruction Set Computers (RISC) designs. It
allows each instruction to operate on any register or use
any addressing mode and simultaneous access of program
and data.

MEMORY ARCHITECTURE
Harvard Memory Architecture Microcontroller: The point
when a microcontroller unit has a dissimilar memory
address space for the program and data memory, the
microcontroller has Harvard memory architecture in the
processor.
Princeton Memory Architecture Microcontroller: The
point when a microcontroller has a common memory
address for the program memory and data memory, the
microcontroller has Princeton memory architecture in the
processor.

Embedded Systems
Embedded system means the processor is embedded into
that application.
An embedded product uses a microprocessor or
microcontroller to do one task only.
In an embedded system, there is only one application
software that is typically burned into ROM.
Example printer, keyboard, video game player

Block Diagram of 8051


External interrupts
Interrupt
Control

On-chip
ROM for
program
code

Timer/Counter

On-chip
RAM

Timer 1
Timer 0

CPU

OSC

Bus
Control

4 I/O Ports

P0 P1 P2 P3

Address/Data

Serial
Port

TxD RxD

Counter
Inputs

The 8051 has an on-chip oscillator but requires an external


clock to run it.
A quartz crystal oscillator is connected to inputs XTAL1 and
XTAL2.
It also needs 2 capacitors of 30pF value.
One side of each capacitor is connected to the ground as
shown below:
C2
XTAL2
30pF
C1
XTAL1
30pF
GND

FEATURES OF 8051
1. 4 KB on chip program memory.
2. 128 bytes on chip data memory(RAM).
3. 4 register banks.
4. 128 user defined software flags.
5. 8-bit data bus
6. 16-bit address bus
7. 32 general purpose registers each of 8 bits
8. 16 bit timers (usually 2, but may have more, or less).
9. 3 internal and 2 external interrupts.
10. Bit as well as byte addressable RAM area of 16 bytes.
11. Four 8-bit ports, (short models have two 8-bit ports).
12. 16-bit program counter and data pointer.
13. 1 Microsecond instruction cycle with 12 MHz Crystal

Registers in 8051
In CPU, registers are used to store information
temporarily. That information could be a byte of data to be
processed, or an address pointing to the data to be fetched.
8051 have 8-bit registers
D7 D6 D5 D4 D3 D2 D1 D0
MSB

LSB

The most widely used registers are A (accumulator), B, R0-R7,


PC (Program Counter).

Program Counter (PC)


PC points to the address of the next instruction to be executed.
As the CPU fetches the opcode from the program ROM, the
PC is incremented to point to the point to the next instruction.
This means that the 8051 can access program address 0000FFFFH, a total of 64Kbytes of code. It is also called
instruction pointer

Flag Bit
8051 has a flag register to indicate arithmetic conditions such
as carry bit. The flag register of 8051 is called Program Status
Word (PSW) register.

PSW (Program Status Word) Register


CY
AC
F0
RS1
RS0
OV
--P

PSW.7
PSW.6
PSW.5
PSW.4
PSW.3
PSW.2
PSW.1
PSW.0

Carry Flag
Auxiliary Carry Flag
Available to the user for general purpose
Register Bank selector bit 1
Register bank selector bit 0
Overflow flag
User-definable bit
Parity flag.(odd/even no of 1 bit in the accumulator)
RS1
0
0
1
1

RS0
0
1
0
1

Register bank
0
1
0
1

Address
00H-07H
08H-0FH
10H-17H
18H-1FH

Its an 8 bit register.


Although it is an 8 bit register, only 6 bits of it are
used. The two unused bits are user definable flags.
Four bits are called conditional flags, they indicate
some conditions that result after an instruction is
executed.
These 4 are CY (carry), AC (Auxiliary Carry), P
(Parity) and OV (Over Flow).

CY flag:- This flag is set when there is a carry out from the D7
bit. This flag bit is affected after an 8-bit addition or
subtraction.
AC flag :- If there is a carry from D3 to D4 during ADD or
SUB operation, this bit is set; otherwise cleared.
P flag :- It reflects the number of 1s in the A (accumulator)
register only. If A register contains an odd number of 1s, then
P=1.If its even, then P=0.
OV Flag :- This is set whenever the result of a signed number
operation is too large, causing the high order bit to overflow
into sign bit.

Example:
1)38h+2Fh=67
0001 1100
+0010 1111
0110 0111
CY=0no carry beyond D7.
AC=1carry from D3 to D4.
P=1 since accumulator has an odd number of 1s.

Stack in 8051
It is a section of RAM.
Stack is used to store information temporarily.
The information could be data or address.

How stack is accessed?


The register used to access the stack is called Stack Pointer
(SP).
SP is 8 bits wide. It can take values 00-FFh.
Storing of a CPU register in stack is called PUSH and
pulling the contents is called POP.

Pin description of 8051

PIN DESCRIPTION
Pins 1-8: Port 1 Each of these pins can be configured as an input or an output.
Pin 9: RS A logic one on this pin disables the microcontroller and clears the contents of
most registers. In other words, the positive voltage on this pin resets the microcontroller.
By applying logic zero to this pin, the program starts execution from the beginning.
Pins10-17: Port 3 Similar to port 1, each of these pins can serve as general input or
output. Besides, all of them have alternative functions:
Pin 10: RXD Serial asynchronous communication input or Serial synchronous
communication output.
Pin 11: TXD Serial asynchronous communication output or Serial synchronous
communication clock output.
Pin 12: INT0 Interrupt 0 input.
Pin 13: INT1 Interrupt 1 input.
Pin 14: T0 Counter 0 clock input.
Pin 15: T1 Counter 1 clock input.
Pin 16: WR Write to external (additional) RAM.
Pin 17: RD Read from external RAM.
Pin 18, 19: X2, X1 Internal oscillator input and output. A quartz crystal which specifies
operating frequency is usually connected to these pins. Instead of it, miniature ceramics
resonators can also be used for frequency stability. Later versions of microcontrollers
operate at a frequency of 0 Hz up to over 50 Hz.

Pin 20: GND Ground.


Pin 21-28: Port 2 If there is no intention to use external memory then these port pins are
configured as general inputs/outputs. In case external memory is used, the higher address
byte, i.e. addresses A8-A15 will appear on this port. Even though memory with capacity of
64Kb is not used, which means that not all eight port bits are used for its addressing, the rest
of them are not available as inputs/outputs.
Pin 29: PSEN If external ROM is used for storing program then a logic zero (0) appears on
it every time the microcontroller reads a byte from memory
Pin 30: ALE Prior to reading from external memory, the microcontroller puts the lower
address byte (A0-A7) on P0 and activates the ALE output. After receiving signal from the
ALE pin, the external register memorizes the state of P0 and uses it as a memory chip
address. Immediately after that, the ALU pin is returned its previous logic state and P0 is now
used as a Data Bus. As seen, port data multiplexing is performed by means of only one
additional (and cheap) integrated circuit. In other words, this port is used for both data and
address transmission.
Pin 31: EA By applying logic zero to this pin, P2 and P3 are used for data and address
transmission with no regard to whether there is internal memory or not. It means that even
there is a program written to the microcontroller, it will not be executed. Instead, the program
written to external ROM will be executed. By applying logic one to the EA pin, the
microcontroller will use both memories, first internal then external (if exists).
Pin 32-39: Port 0 Similar to P2, if external memory is not used, these pins can be used as
general inputs/outputs. Otherwise, P0 is configured as address output (A0-A7) when the ALE
pin is driven high (1) or as data output (Data Bus) when the ALE pin is driven low (0).
Pin 40: VCC +5V power supply.

Reasons for writing programs in C instead of


Assembly
It is easier and less time consuming to write in C than
Assembly.
C is easier to modify and update.
You can use available in-function libraries.
C code is portable to other microcontrollers with little or no
modification.

Program No:- 1
Aim:- Write a program to add two numbers.
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
printf("Enter the two numbers=");
scanf("%d%d",&a,&b);
c=a+b;
printf("Sum=%d",c);
getch();
}
Output:-

Program No:- 2
Aim:- Write a program to check whether the number is greater or not.
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
printf("Enter the two numbers=");
scanf("%d%d",&a,&b);
if(a>b)
printf("a is greater");
else
if (b>a)
printf("b is greater");
else
printf("both the numbers are same");
getch();
}
Output:-

Program No:- 3
Aim:- Write a program to swap the numbers with using 3rd variable.
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c;
printf("Enter the value of a,b");
scanf("%d%d",&a,&b);
c=a;
a=b;
b=c;
printf("%d,%d",a,b);
getch();
}
Output:-

Program No:- 4
Aim:- Write a program to swap the numbers without using 3rd variable.
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a,b;
printf("Enter the two numbers=");
scanf("%d%d",&a,&b);
a=a+b;
b=a-b;
a=a-b;
printf("%d,%d",a,b);
getch();
}
Output:-

Program No:- 5
Aim:- Write a program for doing simple calculations.
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,s,d,m,di;
printf("Enter the two numbers=");
scanf("%d%d",&a,&b);
s=a+b;
d=a-b;
m=a*b;
di=a/b;
printf("Sum= %d, Difference =%d, Multiplication =%d, Division =%d",s,d,m,di);
getch();
}
Output:-

Program No:- 6
Aim:- Write a program to check the number is greater in 3 numbers.
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter the value of a,b,c=");
scanf("%d%d%d",&a,&b,&c);
if (a>b&&a>c)
printf("a is greater");
else if(b>c&&b>a)
printf("b is greater");
else if (c>a&&c>b)
printf("c is greater");
else
printf("a=b=c");
getch();
}
Output:-

Program No:- 7
Aim:- Write a program to separate the 2 numbers of 2 digit number.
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("enter the value of a=");
scanf("%d",&a);
b=a%10;
printf("%d",b);
a=a/10;
printf("\n%d",a);
getch();
}
Output:-

Program No:- 8
Aim:- Write a program to reverse a number.
#include<stdio.h>
#include<conio.h>
void main()
{
int a,i,s=0;
clrscr();
printf("enter the number=");
scanf("%d",&a);
while(a>0)
{
i=a%10;
s=s*10+i;
a=a/10;
}
printf("%d",s);
getch();
}
Output:-

Program No:- 9
Aim:- Write a program to which tells about the input age is of adult or minar.
#include<stdio.h>
#include<conio.h>
void main()
{
int age;
clrscr();
printf("enter the age");
scanf("%d",&age);
if(age>18)
printf("the person is adult");
else
printf("the person is minor");
getch();
}
Output:-

Program No:- 10
Aim:- Write a program to print the numbers from 0 to 99 using the loops.
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
clrscr();
for(i=0;i<=99;i++)
{
printf("%d",i);
}
getch();
}
Output:-

Program No:- 11
Aim:- Write a program to check whether the number is palindrome or not.
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,p,q;
clrscr();
printf("enter the number=");
scanf("%d",&a);
{
p=a%100;
q=a/100;
b=p%10;
c=p/10;
p=b*10+c;
}
if(p==q)
printf("palindrome number");
else
printf("not");
getch();
}
Output:-

Program No:- 12
Aim:- Write a program to print the numbers from 100 to 1 using for loop.
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
for(i=100;i>=1;i--)
{
printf("%d",i);
}
getch();
}
Output:-

C data types for 8051


Unsigned char
8-bit datatype.
value range from 0-255(00-FFh).
Signed char
8-bit datatype.
D7 of D7-D0 represent sign(-ve or +ve).
We have 7 bits for value of signed number.
Range from -128 to 127.
Default is signed value.

Unsigned int
16bit datatype.
value in a range of 0-65535.
used to define 16-bit memory address.
8051 is 8-bit microcontroller, so int datatype take 2bytes of
RAM.

Signed int
16 bit datatype.
Uses MSB (D15 of D15-D0) to represent sign(-ve or +ve).
15 bit for magnitude.
Value range from -32768 to 32767.

Time Delay
There are two ways to create a time delay 8051:
1.Using a simple loop
2.Using the 8051 timers

8051 Timers
Both Timer 0 and Timer 1 are 16 bits wide. Since the
8051 has an 8-bit architecture, each 16-bit timer is accessed as
2 separate registers of low byte and high byte.

Timer 0 Register
The 16-bit registers of Timer 0 are accessed as low byte
and high byte. The low byte is called TL0 (Timer 0 low byte)
and the high byte register is called TH0 (Timer 0 high byte).
These registers can be accessed like any other register, such as
A,B,R0,R1, etc.

TH0

TL0

D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0

Timer 1 register
Timer 1 is also 16 bit register, and its 16-bit register is
split into two bytes, referred to as TL1(Timer 1 low byte) and
TH1 (Timer 1 high byte). These registers are accessible in the
same way as Timer 0.

TH1
D15 D14 D13 D12 D11 D10 D9

TH0
D8

D7

D6

D5

D4

D3

D2

D1

D0

Types of data transfer


Two ways of transferring data:
Parallel
Serial
In parallel data transfer, often 8 or more lines (wire
conductors) are used to transfer data to a that is only a few feet
away.
Ex: printers, hard disk
Each uses cables with many wire strips. Although
in such cases a lot of data can be transferred in a short amount
of time by using many wires in parallel, the distance cannot be
great.

To transfer to a device located many meters away, the serial


method can be used.
In serial communication, the data is send one bit at a time.

Basics of Serial Communication


If data is to be transferred on the telephone line, it must be
converted from 0s and 1s to audio tones, which are sinusoidal
shaped signal. This conversion is performed by a peripheral
device called as MODEM=modulator/demodulator.
Serial data communications uses two methods
1.Synchronous method transfers a block of data
(character) at a time.
2.Asynchronous method transfers a single byte at
a time.

Half and Full duplex transmission


In data transmission if the data can be transmitted and
received, it is a duplex transmission.
Parallel Transfer
D0

Serial Transfer
Sender

Receiver

Sender

Receiver
D7

Simplex

Half Duplex

Full Duplex

Transmitter

Receiver

Transmitter

Receiver

Receiver

Transmitter

Transmitter

Receiver

Receiver

Transmitter

Asynchronous serial communication and data


framing
Start and Stop bits
Asynchronous serial communication is widely used for
character-oriented transmission, while block-oriented data
transfer uses synchronous method.
In asynchronous method, each character is placed between
start and stop bits. This is called framing.
Start bit is always one bit and it is a low bit
Stop bit can be one or two bits and it is a high bit

space

stop
bit

Goes out last

0
D7

1
D0

start
bit

Goes out first

Вам также может понравиться