ESAD file Arnav
ESAD file Arnav
NAME: Ashish
CLASS & ROLL NO.: ECE 2 | 08413202822
SUBMITTED TO: DR. GAGANDEEP KAUR
INDEX
EXPERIMENT-1
AIM:
Introduc on to 8051 Microcontroller.
APPARATUS USED:
In lab we have used ANSHUMAN 8051 MICROCONTROLLER KIT
THEORY:
History:
Early 1970s: The race is on! Around the same me Intel created the first
microprocessor, the 4-bit Intel 4004, engineers at Texas Instruments
were working on a similar concept.
1977: Intel responds to the popularity of the TMS 1000 with the Intel
8048,
another single-chip design that combined RAM and ROM with a
microprocessor. This chip found its way into millions of PC keyboards.
Increasing Complexity: Bit size grew from 4-bit to 8-bit, 16-bit, 32-bit
and beyond, enabling more complex tasks.
Re-programmability: Early microcontrollers required specialized
equipment for programming. The introduc on of erasable
programmable memory (like flash memory) allowed for easier updates
and development.
Complexity:
Applica ons:
Analogy:
Think of a microprocessor as a powerful, expandable desktop computer.
Types of Buses:
8. Data Types: In 8051, there is only one data type of 8 bits, from
the MSB (most significant bit) D7 to the LSB (least significant bit) D0.
With an 8-bit data type, any data type larger than
10. Registers: Registers are memory storage devices used in the CPU
to temporarily store informa on. This informa on could be data to be
processed or, an address poin ng to the data to be fetched.
Addi onally, it func ons as the high-order address bus for accessing
external memory.
A bidirec onal 8-bit I/O port with addi onal specific func onality is port
3.
It contains two external interrupt pins (INTO, INTI) that can cause
hardware interrup ons from outside the device.
TXD and RXD, two addi onal pins, are provided for serial
communica on.
It is a pulse signal produced by the 8051 to let other devices know that
the data on the address bus is legi mate.
EA/VPP is used for two different func ons depending on its logic level.
When connected to VCC (5V), it enables the 8051 to fetch code from
external memory.
When ac vated, it informs the external ROM that the 8051 is fetching
instruc ons.
These are the connec ons for an external crystal oscillator or resonator.
They are used to provide the clock signal for the microcontroller.
Low Cost: The 8051 is cost-effec ve for a wide range of applica ons,
making it a go-to choice for budget-sensi ve projects.
Simple Architecture: Its straigh orward architecture is easy to
understand and program, ideal for beginners and complex projects
alike.
Versa le I/O Opera ons: Provides a variety of built-in I/O opera ons,
including mers, serial communica on, and interrupt handling,
facilita ng diverse applica ons.
Limited Memory: The standard 8051 comes with only 4KB of ROM and
128 bytes of RAM, which may not suffice for more complex applica ons.
Versa le Instruc on Set: The 8051 packs a powerful instruc on set for
an 8-bit microcontroller. It supports a variety of arithme c, logical, and
branching opera ons, allowing you to tackle a wide range of tasks
within its processing capabili es.
Wide Availability and Strong Community Support: The 8051 has been
around for a long me and remains a popular choice. This translates to
easy availability, a wealth of documenta on and tutorials, and a strong
community of developers you can tap into for help.
AIM:
Write a program to perform addi on and subtrac on of two numbers.
SOFTWARE USED: Keil Vision5
PROGRAM
#include <reg51.h>
void main(void)
{ unsigned char a, b, c, m, n, o, p, q, r, x, y, z;
a=0x03;
b=0x05
:
c=a+ b; // perform addi on
m=0x0a;
n=0x04;
o=m-n ; // perform subtrac on
P0=c;
P1=o;
}
OUTPUT
EXPERIMENT -3
AIM:
Write a program to perform mul plica on and division of two numbers.
SOTWARE
USED: Keil u
vision 5
PROGRAM
#include <reg51.h>
void main(void)
{
unsigned char a, b, c, m, n, o, p, q,
r, x, y, z; p=0x04; q=0x06; r=p/q;
x=0x02; y=0x04;
z=x*y;
P2=r;//perform division
P3=z;//perform mul plica on
}
OUTPUT
EXPERIMENT-4
AIM:
Write an 8051 C program to send hex values for ASCII characters of 0, 1, 2, 3, 4, 5, 6,
7, 8, 9, A, B, C, D, E to Pl.
SOFTWARE
USED:
Keil uVision5
PROGRAM
CODE:
#include<reg51.h>
void main(void)
{
unsigned char mynum[] = "0123456789ABCDE";
unsigned char z;
for(z=0; z <= 15; z++)
{ P1 = mynum[z];
}
}
OUTPUT:
EXPERIMENT - 5
AIM:
So ware
Required:
Keil uVision5
C
o
d
e
:
//factorial of a number
#include <reg51.h>
while(n>1){
result *=n;
n
-
;
}
return result;
}
void main(void) {
result = factorial(num);
P1 = result;
while(1);}
OUTPUT
EXPERIMENT-6
AIM:
Write a C program to toggle bits of P1 ports con nuously with a 250 ms.
So ware
Required:
Keil uVision5
PROGRAM
CODE
#include <reg51.h>
void main()
P1 = 0x55;
MSDelay(1000);
P1 = 0xaa;
MSDelay(1000);
}
//delay rou ne implimenta on
unsigned int i, j;
for(i=0; i < i me; i++)
for(j=0;j<1275; j++);
}
OUTPUT:
EXPERIMENT - 7
AIM:
Write an 8051 C program to get byte of data from P1, wait ½ second (i.e 500ms) and
then send it to P2.
SOFTWARE
USED:
Keil uVision5.
PROGRAM
CODE:
#include <reg51.h>
void main()
while(1)
P2mybyte; // sending to p2
void MSDelay(unsigned int i me)
unsigned int i, j;
for(i=0; i<i me; i++)
OUTPUT:
EXPERIMENT-8
AIM:
Write an 8051 C program to send the two messages "first name" and "last name" to
the serial port. If SW-0, send first name else if SW-1, send last name.
SOFTWARE
USED:
Keil uVision5.
PROGRAM
CODE:
#include <reg51.>
void main(void)
unsigned char z,
TMOD=0x20;
TH1 = 0xfd;
SCON = 0x50;
TRI=1;
if (SW==0)
{
for(z=0; z < 3; z++) {
SBUF=first_name[z];
while(T1==0)
TI=0;
}
}
else {
for(z=0; z <4; z++)
{
SBUF=last_name[z].
while(TI==0);
T1 =0;
}
}
}
OUTPUT:
EXPERIMENT 9
AIM: Write an 8051 C program to send the two messages "first name" and
"last name'* to the serial port. If SW=O, send first name else if l, send last
name.
SOFTWARE USED: Keil uVision5.
PROGRAM CODE:
#include <rcg51 .h>
unsigned char SW;
void main(void)
{unsigned char z;
unsigned char first_name[] = "NEW";
unsigned char last_name[] = “USER";
TMOD = 0x20;
THI = 0xfd;
SCON = 0x50;
TRI= I;
If (SW =0)
{
for(z = 0; z < 3; z++)
{
SBUF = first_name[z];
while(Tl ==0)
T1 =0;
}
}
else
{
for (0: •z < 4;z++)
{
SBUF = last_name[z];
while(T!==0)
T1=0;
}
}
}
OUTPUT:
EXPERIMENT 10
AIM: To use Embest IDE for ARM and ARM So ware Emulator.
THEORY:
Embest IDE is an Integrated Development Environment for so ware cross-
development, The EmbestlDE is an applica on that provides a simple and
graphical user interface and tools for developing embedded so ware. It
is an Integrated Developnent Environment (IDE) that facilitates managing
and building projects, establishing and managing host-target
communica on, Illnning and debugging applica ons. It provides an
efficient way for developing embedded applica ons. EmbestlDE
comprises the following elements (Figure I-I):
An integrated source-code editor
A project management facility.
Integrated C and ASM compilers and linker. Z
a source-level debugger.
an integrated development environment.
an ARM simulator
EmbestIDE uses host-larger cross model for developing embedded
applica ons. EmbestlDE runs on a host computer. Your target board is
connected to the host computer through debug device (BDM/JTAG
Emulator). You can edit and build your projects on the host, and create a
target executable file with EmbestIDE. Download the target file to the
target, and then use Embes0DE debugger 10 debug it through the
communica on of debug device connected between the host computer
and the target board. Figurel-2 illustrates the host-target cross model with
EmbestIDE.
When you use EmbestIDE for ARM, a debug device--Embest JTAG
Emulator is provided. See appendix A "JTAG Emulator Connec on" for
detail describe about Embest JTAG Emulator.
Simple Example
This sec on shows users step by step how to create, compile and debug
a simple project. The project described below is to create a random
number. The project demo locates at under
Embest1DE installing directory. The files to be used are:
Random.s Assemble file ofrandom number
func on
Randtest. Main program file
Create a Project
J) Crea ng Project
Select File > New Workspace menu, Give a project name and specify
project directory as shown
Rantest has been used as a project name, and project directory has been
specified as D:/EmbestIDE\Example\arm250\explasm\,D:\EmbestIDE is
default installing directory of EmbestIDE unless noted.
A er clicking OK, two files will bc created in the project directory:
Rantest.cws Workspace file
A er the proJect has been created, files pane will appear in Embest IDE
workspace Window as shown in Figure 3-2.
You can add the source files in the pop up dialog box. To select source
files, press CTRL key and hold, click source files of random.s and randtest.c
in Project directory, See Figure 3-4.
Figure 3-5. Workspace window
2) Emulator Se ngs
Select Remote pane from Project Se ngs dialog. Define Remote Device
as jtagarm7. Because of Embest Emulator for ARM does not support to
change the working speed, don't worry about the se ng of Speed item.
When using Embest PowerlCE for ARM, select the valid work speed: Full
Speed(120Kbyte/s). High Speed. Medium Speed, Low Speed.
Communica on port with remote device is PARALLEL. Communica on
channel is LPTI as show.
3) Debug Se ngs
Select Debug pane from Project Se ngs dialog. Select General from
Category, Set symbol file as
/debug/rantest.elf and Ac on a er connected as None.
4) Compiler se ngs
Set compiler pane from project se ngs dialog.set onject files loca on as
./debug and other
5) Assembler Se ngs
Select assembler pane from project se ngs dialog. Set object files
loca on as.\ debug and others as default.
6) Linker Se ngs
Select linker pane from project se ngs dialog. Select general from object
set object file loca on as debug and others as default.
OUTPUT:
EXPERIMENT 12
AIM: Write a program to mul ply two numbers using ARM processor.
SOFTWARE USED: Keil ARM IDE.
Program code:
OUTPUT: