Microcontroller & Embedded Systems Lab Manual Exp.1,2,3
Microcontroller & Embedded Systems Lab Manual Exp.1,2,3
UNIT-I
8051 interfacing to ADC and DAC, Stepper motor interfacing, Timer/ counter functions, 8051
based data acquisition system 8051 connections to RS-232, 8051 Serial communication, Serial
communication modes, Serial communication programming, Serial port programming in C.
UNIT II:
UNIT-III
Definition of embedded system, embedded systems vs. general computing systems, history of
embedded systems, classification, major application areas, purpose of embedded systems,
characteristics and quality attributes of embedded systems, common design metrics, and
processor technology: general purpose processor, application specific processor, single purpose
processor.
UNIT-IV
Embedded System Architecture:
Von Neumann v/s Harvard architecture, instruction set architecture, CISC and RISC
instructions set architecture, basic embedded processor, microcontroller architecture, CISC &
RISC examples: 8051, ARM, DSP processors.
UNIT-V
Reference Books:
1. Muhammad Ali Mazidi and Janice Gillespie Mazidi, The 8051 Microcontroller and Embedded
Systems, Pearson education, 2005.
2. Kenneth J. Ayala, The 8051 Microcontroller Architecture, III edition, CENGAGE Learning.
4. McKinlay, The 8051 Microcontroller and Embedded Systems - using assembly and C, PHI, 2006 /
Pearson, 2006.
5. Tim Wilmshurst, Designing embedded system with PIC microcontrollers Principles and applications.
2nd ed. 2011 Bsp books pvt lt
7. David E Simon, “An Embedded Software Primer”, Pearson education Asia, 2001.
8. Steven F. Barett, Daniel J. Pack, “Embedded Systems” Pearson education, First Impression2008.
RAJIV GANDHI PROUDYOGIKI VISHWAVIDYALAYA, BHOPAL
Description
The AT89C51 is a low-power, high-performance CMOS 8-bit microcomputer with 4K bytes of Flash
programmable and erasable read only memory (PEROM). The device is manufactured using Atmel’s high-density
nonvolatile memory technology and is compatible with the industry-standard MCS-51 instruction set and pinout.
The on-chip Flash allows the program memory to be reprogrammed in-system or by a conven- tional nonvolatile
memory programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C51 is
a powerful microcomputer which provides a highly-flexible and cost-effective solution to many embedded control
applications.
Features
• Compatible with MCS-51™ Products
• 4K Bytes of In-System Reprogrammable Flash Memory
– Endurance: 1,000 Write/Erase Cycles
• Fully Static Operation: 0 Hz to 24 MHz
• Three-level Program Memory Lock
• 128 x 8-bit Internal RAM
• 32 Programmable I/O Lines
• Two 16-bit Timer/Counters
• Six Interrupt Sources
• Programmable Serial Channel
• Low-power Idle and Power-down Modes
•
Pin Configurations
Block Diagram
VCC
PROGRAM
B STACK ADDRESS
REGISTER ACC POINTER REGISTER
BUFFER
TMP2 TMP1
PC
ALU INCREMENTER
PROGRAM
PSW COUNTER
PSEN
ALE/PROG TIMING
AND INSTRUCTION REGISTER DPTR
EA / VPP CONTROL
RST
PORT 1 PORT 3
LATCH LATCH
OSC
PORT 1 DRIVERS PORT 3 DRIVERS
P1.0 - P1.7
P3.0 - P3.7
Pin Description Port 0
Port 0 is an 8-bit open-drain bi-directional I/O port. As
an output port, each pin can sink eight TTL inputs.
VCC
When 1s are written to port 0 pins, the pins can be
Supply voltage. used as high- impedance inputs.
Port 0 may also be configured to be the multiplexed
GND low- order address/data bus during accesses to external
Ground. pro- gram and data memory. In this mode P0 has
internal pullups.
Port 0 also receives the code bytes during Flash P3.1 TXD (serial output port)
program- ming, and outputs the code bytes during P3.2 INT0 (external interrupt 0)
program verification. External pullups are required P3.3 INT1 (external interrupt 1)
during program verification.
P3.4 T0 (timer 0 external input)
P3.5 T1 (timer 1 external input)
Port 1
P3.6 WR (external data memory write strobe)
Port 1 is an 8-bit bi-directional I/O port with internal P3.7 RD (external data memory read strobe)
pullups. The Port 1 output buffers can sink/source
four TTL inputs. When 1s are written to Port 1 pins Port 3 also receives some control signals for Flash
they are pulled high by the internal pullups and can be pro- gramming and verification.
used as inputs. As inputs, Port 1 pins that are
externally being pulled low will source current (IIL) RST
because of the internal pullups. Reset input. A high on this pin for two machine
Port 1 also receives the low-order address bytes cycles while the oscillator is running resets the
during Flash programming and verification.
device.
Port 2
Port 2 is an 8-bit bi-directional I/O port with internal
ALE/PROG
pullups. The Port 2 output buffers can sink/source
four TTL inputs. When 1s are written to Port 2 pins Address Latch Enable output pulse for latching the
they are pulled high by the internal pullups and can low byte of the address during accesses to external
be used as inputs. As inputs, Port 2 pins that are memory. This pin is also the program pulse input
externally being pulled low will source current (IIL) (PROG) during Flash programming.
because of the internal pullups. In normal operation ALE is emitted at a constant rate
Port 2 emits the high-order address byte during of 1/6 the oscillator frequency, and may be used for
fetches from external program memory and during external tim- ing or clocking purposes. Note,
accesses to external data memory that use 16-bit however, that one ALE pulse is skipped during each
addresses (MOVX @ DPTR). In this application, it access to external Data Memory.
uses strong internal pullups when emitting 1s.
During accesses to external data mem- ory that use If desired, ALE operation can be disabled by setting
8-bit addresses (MOVX @ RI), Port 2 emits the bit 0 of SFR location 8EH. With the bit set, ALE is
contents of the P2 Special Function Register. active only dur- ing a MOVX or MOVC instruction.
Port 2 also receives the high-order address bits and Otherwise, the pin is weakly pulled high. Setting the
some control signals during Flash programming and ALE-disable bit has no effect if the microcontroller is
verification. in external execution mode
PSEN
Port 3 Program Store Enable is the read strobe to external
Port 3 is an 8-bit bi-directional I/O port with internal pro- gram memory.
pullups. The Port 3 output buffers can sink/source When the AT89C51 is executing code from external
four TTL inputs. When 1s are written to Port 3 pins pro- gram memory, PSEN is activated twice each
machine cycle, except that two PSEN activations are
they are pulled high by the internal pullups and can skipped during each access to external data memory.
be used as inputs. As inputs, Port 3 pins that are
externally being pulled low will source current (IIL) EA/VPP
because of the pullups.
External Access Enable. EA must be strapped to GND
Port 3 also serves the functions of various special
in order to enable the device to fetch code from
features of the AT89C51 as listed below:
external pro- gram memory locations starting at 0000H
up to FFFFH. Note, however, that if lock bit 1 is
Port Pin Alternate Functions
programmed, EA will be internally latched on reset.
P3.0 RXD (serial input port)
EA should be strapped to V CC for internal
program executions.
This pin also receives the 12-volt programming
enable volt- age (VPP) during Flash programming, for
parts that require 12-volt VPP.
XTAL1
Input to the inverting oscillator amplifier and input to
the internal clock operating circuit.
XTAL2
Program-
#include<reg51.h>
void delay(unsigned int itime);
void main()
{
P2=0x55;
delay(100);
P2=0xaa;
delay(100);
}
void delay(unsigned int itime)
{
unsigned int i,j;
for(i=0;i<=itime;i++)
for(j=0;j<=1275;j++);
}
II-Program for two group of blinking of leds all the bits of P2.
#include<reg51.h>
void delay(unsigned int itime);
void main()
{
P2=0xcc;
delay(100);
P2=0x33;
delay(100);
}
void delay(unsigned int itime)
{
unsigned int i,j;
for(i=0;i<=itime;i++)
for(j=0;j<=1275;j++);
}
III-Program for four group of blinking of leds all the bits of P2.
#include<reg51.h>
void delay(unsigned int itime);
void main()
{
P2=0xf0;
delay(100);
P2=0x0f;
delay(100);
}
void delay(unsigned int itime)
{
unsigned int i,j;
for(i=0;i<=itime;i++)
for(j=0;j<=1275;j++);
}
#include<reg51.h>
void Delay(unsigned int itme);
void main( )
{
while(1)
{
P2=0xc0;
Delay(100);
P2=0xf9;
Delay(100);
P2=0x24;
Delay(100);
P2=0xb0;
Delay(100);
P2=0x99;
Delay(100);
P2=0x92;
Delay(100);
P2=0x02;
Delay(100);
P2=0x78;
Delay(100);
P2=0x00;
Delay(100);
P2=0x01;
Delay(100);
}
}
void Delay(unsigned int itime)
{
unsigned int i,j;
for(i=0;i<=itime;i++)
for(j=0;j<=1275;j++);
}
Result- Program for displaying 0-9 on seven segment and there simulation on protious successfully
completed.