Sei sulla pagina 1di 4

Microcontroller and Microprocessor lab 5

Lab - 5: Introduction to 8051 Microcontroller


5.1 OBJECTIVE :
 To examine and use 8051 microcontroller, assembler and simulator
 To learn “in system programming” (ISP) of microcontroller
5.2 PRE-LAB READING:
Chapter 1, 2, 8, Mazidi and McKinlay, “The 8051 Microcontroller and Embedded Systems”
5.3 EQUIPMENT REQUIRED
Instruments Oscilloscope
8051 ETK Trainer
Components Resistor 8.2k, 10k
Capacitors 10 uF, 30 uF, 30 uF
ICs 89C51RD2

5.4 MICROCONTROLLER WITH MINIMUM CONNECTIONS:


8051 microcontroller has 40 pins, out of which 32 pins are for four eight bit I/O ports. Apart from general
usage, port 3 is also used for specific tasks and each pin of this port has special purpose. A crystal
oscillator is attached at pin 18 and 19 along with capacitors. In case the microcontroller is to be derived
from external clock, pin 18 is left with no connection and external clock is given at pin 19. Vcc is applied
at pin 40 and 31 while pin 20 is connected to ground. In case pin 31 is left low, microcontroller will not
use internal ROM to run, rather it will execute the program from external ROM (if connected). Thus in
normal case, when the program is written in internal ROM, EA pin is given high logic. Pin 9 is RESET. If
this pin is kept high for at least two machine cycles, microcontroller resets and terminates all activities.

5.5 IN SYSTEM PROGRAMMING (ISP):


In-System Programming (ISP) is performed without removing the microcontroller from the system. The
In-System Programming (ISP) facility consists of a series of internal hardware resources coupled with
internal firmware to facilitate remote programming of the microcontroller through the serial port. This
firmware is embedded within each P89C51RB2/RC2/RD2Hxx device. The ISP function uses five pins:
TxD, RxD, VSS, VCC, and VPP as shown in figure 1.1.
When the microcontroller programs its own Flash memory, all of the low level details are handled by
code that is permanently contained in a 1-kbyte Boot ROM that is separate from the Flash memory. A
user program simply calls the common entry point with appropriate parameters in the Boot ROM to
accomplish the desired operation. Boot ROM operations include things like: erase block, program byte,
verify byte, program security lock bit, etc. The Boot ROM overlays the program memory space at the top
of the address space from FC00 to FFFF hex, when it is enabled. If the flash memory of microcontroller is
completely erased, Boot ROM will also be erased which will make our microcontroller useless. Such
microcontroller will not be programmed by ISP. Therefore, never erase full memory blocks of
microcontroller. Figure 1.2 shows flash memory configuration and position of Boot ROM in flash
memory of microcontroller.

1
21395
Microcontroller and Microprocessor lab 5

5.6 PRECAUTIONS FOR ENTIRE COURSE


 Do not erase full memory blocks of the microcontroller.
 Remember to initialize the ports of the microcontroller.
 Do not at any point draw more than 26mA from the microcontroller.
5.7 ACTIVITIES AND EXERCISES

2
21395
Microcontroller and Microprocessor lab 5

1. This task is designed to get you familiar with ASEM-51 assembler. Write a simple assembly language
code in which you move a value in register A. Then from register A, move this value to registers R0-R7.
Save this file as .asm and generate .hex file and simulate it. Write the code in following space. A
microcontroller simulator helps in viewing the inside of a microcontroller. Hex file of code is loaded in
the simulator which shows the code in ‘disassembled code window’. Values of different registers and data
in RAM is also shown and updated at each step of the code.

ORG 00H
Mov A, #0BH
MOV R0, A
MOV R2, A
MOV R3, A
MOV R4, A
MOV R5, A
MOV R6, A
MOV R7, A
END
2. Write an assembly language code in which a value is moved in register A. Then from register A, 06H is
added to this value and moved to register R0. Keep adding 06H and move the data from R1 to R7
registers. Now load the hex file of this code in the simulator and use the simulator to single step the
program. Examine and write down the values of registers (PC, ACC, and R0-R9) on each step and show
to your instructor.

ORG 00H
Mov A, #10H
ADD A, #06H
Mov R0, A
ADD A, #06H
Mov R1, A
ADD A, #06H
Mov R2, A
ADD A, #06H
Mov R3, A
ADD A, #06H
3
21395
Microcontroller and Microprocessor lab 5

Mov R4, A
ADD A, #06H
Mov R5, A
ADD A, #06H
Mov R6, A
ADD A,#06H
Mov R7,A
END
5.8 Assessment sheet:
CMS ID: 21395
DATE: 04-05-2015

1-introduction to 8051
Problem Number
2-description

Working
Lab Performance
Viva

Total Score in Lab#5

Instructor's Verification

4
21395

Potrebbero piacerti anche