8051 Manual
8051 Manual
LTD
8051 MICROCONTROLLER
                                                  PS – TRAINER-8051B
USER MANUAL
1
                                       PS – 8051 USER MANUAL
                                                                           PS-8051
               PANTECH PROLABS INDIA PVT.LTD
TABLE OF CONTENTS
2
                                 PS – 8051 USER MANUAL
                                                            PS-8051
               PANTECH PROLABS INDIA PVT.LTD
    6.1    ADDITION                                    22
    6.2    SUBTRACTION                                 23
    6.3    MULTIPLICATIONS                             24
    6.4    DIVISION                                    25
    6.5    MULTI BYTE ADDITION                         26
    6.6    LARGEST ELEMENT IN AN ARRAY                 28
    6.7    PROGRAMS FOR SORTING                        29
    6.8    BCD TO HEX CONVERSION                       30
    6.9    HEX TO BCD CONVERSION                       31
    6.10   ASCII TO HEX CONVERSION                     32
    6.11   SQUARE ROOT OF A GIVEN NUMBER               33
    6.12   PARITY GENERATION                           34
3
                               PS – 8051 USER MANUAL
                                                        PS-8051
                      PANTECH PROLABS INDIA PVT.LTD
                             CHAPTER 1: INTRODUCTION
1.1 WELCOME
       Thank you for purchasing PS-8051 Board from PANTECH PROLABS INDIA PVT LTD. The PS-8051
board which demonstrates the capabilities of the 40-pin 8051 (various families) Sample programs are
provided to demonstrate the unique features of the supported devices.
 4
                                              PS – 8051 USER MANUAL
                                                                                     PS-8051
                     PANTECH PROLABS INDIA PVT.LTD
       The PS – 8051 board is based on Intel 8051Microcontroller which operates at 11.0592 MHZ. The
board can   operate using 101/104 PC keyboard supplied along with the trainer kit and 2 line by 16
characters LCD display or from the PC (using the Terminal Emulation Software).   PS – 8051 is equipped
with powerful software monitor in 27C256 EPROM. Keyboard and LCD display. The board has 32KB CMOS
static RAM (type 62256). PS – 8051 works on +9V DC at 1 Amp.
 5
                                           PS – 8051 USER MANUAL
                                                                                 PS-8051
                       PANTECH PROLABS INDIA PVT.LTD
6
                                             PS – 8051 USER MANUAL
                                                                                  PS-8051
                    PANTECH PROLABS INDIA PVT.LTD
MEMORY:
ALLOCATION OF EPROM:
ALLOCATION OF RAM:
 7
                                         PS – 8051 USER MANUAL
                                                                        PS-8051
                          PANTECH PROLABS INDIA PVT.LTD
PARALLEL INTERFACE:
CONNECTOR DETAILS
      The 20 Pin FRC connector is used to interconnect with the Interface cards like ADC, DAC,
SWITCH/LED, RELAY buzzer Interfaces etc. Pin details are given below
             J1                             J4                             J3
 8
                                                 PS – 8051 USER MANUAL
                                                                                        PS-8051
                      PANTECH PROLABS INDIA PVT.LTD
       The 50 Pin FRC connector is used to interconnect with the Interface cards like 8255, 8279,
8253/8251, 8259 ….
                                                                  J6
                                           GND            1             2
                                           D0             3             4         D1VCC
                                           D2             5             6         D3
                                           D4             7             8         D5
                                           D6             9             10        D7
                                           A0            11             12        A1
                                           A2            13             14        A3
                                           A4            15             16        A5
                                           A6            17             18        A7
                                           A8            19             20        A9
                                           A10           21             22        A11
                                           A12           23             24        A13
                                           A14           25             26        A15
                                           PCLK          27             28
                                           RST           29             30
                                                         31             32    INT0
                                           INT1          33             34
                                                         35             36        RD
                                           WR            37             38
                                           ALE           39             40      EA
                                           PSEN          41             42    CS6
                                           CS7           43             44    CS8
                                           CS9           45             46
                                           RXD           47             48    TXD
                                           VCC           49             50    GND
KEYBOARD CONNECTOR:
                      5V
            R13                                   R12
            1K                                    1K
                           PS2
                      5
PC07 2 8 PC06
1 6
                                 JP1
                      3
PIN NO SIGNAL
8,6 DATA
5 VCC
                           3                                      GND
 9
                                                          PS – 8051 USER MANUAL
                                                                                          PS-8051
                    PANTECH PROLABS INDIA PVT.LTD
                                             NC
                                             NC
     P1
          1                                  RXD
          6
          2
          7                                  CTS
          3
          8
          4                                  TXD
          9
          5
                                             NC
                                             NC
                                             NC
                                             GND
 DRIVERS USED:
          MAX 232 is used for transmitting receiving of characters.
10
                                         PS – 8051 USER MANUAL
                                                                      PS-8051
                         PANTECH PROLABS INDIA PVT.LTD
LCD CONNECTOR
LCD
                                    JP1
                                                                 1
                                       1
                                       2            LCD      2
                                       3       RS
                                       4       RW                      10K
                                       5       E                       R1
                                       6       D0
                                       7                         3
                                               D1
                                       8       D2
                                       9       D3
                                      10       D4
                                      11       D5
                                      12       D6
                                      13       D7
                                      14
                                      15
                                      16
         PS trainer kit will work at 0 – 9v (1 amp) from the PS power supply. Provision is made in PS power supply to
bring out on the front panel DC regulated voltage output for interfacing with add-on cards.
    +9V           1 amp
 11
                                                 PS – 8051 USER MANUAL
                                                                                                 PS-8051
                         PANTECH PROLABS INDIA PVT.LTD
        101 PC type keyboard is interfaced to Microcontroller through its port pin. Communication between
keyboard and Microcontroller takes place using 2 wires – one for serial clock and serial data (P1.6 and P1.7).
                     A <BEG>                              ASSEMBLE
                     B                                    BAUD RATE
                     D <BEG>                              DISASSEMBLE
                     E <BEG> <END>                        EXAMINE
                     G <BEG>                              EXECUTE
                     H                                    HELP COMMANDS
                     I <ADDR>                             INTERNAL RAM
                     L <OFFSET>                           DOWNLOAD
                     M <ADDR>                             MODIFY
                     N                                    NORMAL MODE
                     Q                                    QUIT
 12
                                                 PS – 8051 USER MANUAL
                                                                                            PS-8051
                        PANTECH PROLABS INDIA PVT.LTD
4.1 POWER ON
         Connect the PS – 8051 board to the power having the following specifications.
                                   +9V DC 1 Amp
Switch on the power supply after ensuring the correct voltages. Following message will appear on the LCD display.
                                                    PAN TECH
                                                       8051
On power on or after reset the display shows PANTECH 8051 as a sign on message. The prompt character – is
displayed in the next line informing the user, that the board is ready to accept the commands.
ENTERING MNEMONICS
Example:
       PAN TECH                  Enter the starting Address
 ▁a8500
Enter Key
User program starts from address 8500. Display the following and waits for the user data to be typed in
the second line.
EXAMPLE:
 8500:
 mov a,#12                       Type the Mnemonics
Enter Key
 8502:
 mov b,#12
 13
                                                 PS – 8051 USER MANUAL
                                                                                          PS-8051
                          PANTECH PROLABS INDIA PVT.LTD
Enter Key
 EXIT COMMAND:
Double enter you get the main menu
Enter Key
 8500:
 4A ▁
 14
                                              PS – 8051 USER MANUAL
                                                                      PS-8051
                          PANTECH PROLABS INDIA PVT.LTD
 Enter key
After executing display
  ▁                            Executing display
Enter Key
4.4 DISASSEMBLER
Disassemble converts the hex byte stored in the memory into equivalent mnemonics. To enter into
disassemble mode, type D in the command mode followed by the memory address.
EXAMPLE:
 Press H for help              Enter the Starting Address
 ▁d8500
Enter Key
 8500: 74 12
 MOV A,#12
 8502: 75 0B 12
 MOV B,#12
Enter the space bar key
 15
                                              PS – 8051 USER MANUAL
                                                                           PS-8051
                           PANTECH PROLABS INDIA PVT.LTD
Using this command the user can display/modify any external memory address.
Modify External memory
R (REGISTER DISPLAY)
EXAMPLE:
 Press H for help                  Enter the starting Address
 ▁RA
Enter Key
A = FF
T (TRANSFER COMMAND)
EXAMPLE:
                     T8500 8600 9000 Press Enter Key.
The above command transfer the memory content starting from source start address 8500 to destination
start address 8600 till source end address 9000 is reached
   Starting address                       8500
   End address                            8600
   Destination address                    9000
                                                                              PS-8051
                            PANTECH PROLABS INDIA PVT.LTD
Enter Key
 T: 8500 to 9000
 ▁
N (LOCAL MODE)
When this key is depressed on PC keyboard, the PS – 8051 Kit starts working through local 101 key
keyboard. Serial communication is disabled. Following message will appear in the LCD display.
        ! Normal Mode!
B (BAUD RATE)
     Press the ‘B ‘
 BAUD RATE : @0150
  @150                               Enter the Space Bar Key to change Baud Rate
This command is similar to that of modify external except it displays/modifies internal 128 bytes of 8051
Microcontroller. Use of UP, DOWN and ENTER keys are also as described above. The example program is
given in chapter 6
Note: This command is one of the important commands used to modify the internal memory of controller.
 17
                                                 PS – 8051 USER MANUAL
                                                                                   PS-8051
                     PANTECH PROLABS INDIA PVT.LTD
18
                                           PS – 8051 USER MANUAL
                                                                          PS-8051
                    PANTECH PROLABS INDIA PVT.LTD
 To verify the code depress D starting address and depress space bar to see next memory location
For Ex: D8500 and press spacebar till the end of the program
 To view the output in the Register depress ‘R’ and press enter key in keyboard.
 To view the code depress D starting address and depress space bar to see next memory location
For Ex: D8500 and press spacebar till the end of the program
 To execute the program Depress “G staring address for Ex: G8500 and press Reset Switch(SW2)
19
                                             PS – 8051 USER MANUAL
                                                                                PS-8051
                         PANTECH PROLABS INDIA PVT.LTD
 To view the output in the Register depress ‘R’ and press enter key in keyboard
Note: 1) “M” is used for displaying the result, for Ex: M8500
          1) Mnemonics method
          2) Opcode method
This chapter describes the technique for developing program in PS – 8051 board. For the development of
program it is essential to get familiar with the machine code of 8051 Microcontroller or mnemonics of
instruction set.
5.1 REGISTERS:
From the programmer’s point of view 8051 has the following register:
     A or Accumulator used for all logical and arithmetical operations.
     B register (8 bit) used in multiply/divides instructions only.
     R0, R1, R2, R3, R4, R5, R6, and R7 register are general-purpose registers.
     Program counter is 16 bit register capable of addressing from 0000-FFFF
     Stack pointer is an 8-bit register. It is initialized a value of 70, please note the value of SP is
          incremented by 1 or 2 (whereas SP decrements 1 or 2 in 8085 or Z80) depending on the type of
          instructions. Also stack uses only internal 128 bytes of memory.
     Status/Flag register keeps track of flags.
 20
                                                PS – 8051 USER MANUAL
                                                                                    PS-8051
                          PANTECH PROLABS INDIA PVT.LTD
5.3     BREAKPOINT:
When writing program it is essential to debug them and for this break points are necessary. Normally these
are achieved by using software Break points. However 8051 does not have any such facility. Other
conventional methods require extra hardware and hence these are avoided in PS – 8051 board.
Wherever break points are required they can be called like subroutines. As soon as break point is called all
the register values are saved and displayed on the console or in local display.
It is possible to continue the program execution just by depressing G and enter in local mode.
                                                                                              PS-8051
                       PANTECH PROLABS INDIA PVT.LTD
When break point is encountered, all the register values are saved and the Acc. Value is displayed in the
LCD display. Now use SPACE key to check register values one by one.
ALGORITHM:
INPUT:
                MOV A,# 13
                ADD A,#14
OUTPUT:
              8600       27H
PROGRAM:
 22
                                                PS – 8051 USER MANUAL
                                                                                              PS-8051
                        PANTECH PROLABS INDIA PVT.LTD
ALGORITHM:
INPUT:
               MOV A,# 20
               SUBB A,#10
OUTPUT:
             8600         10H
PROGRAM:
23
                                               PS – 8051 USER MANUAL
                                                                                             PS-8051
                        PANTECH PROLABS INDIA PVT.LTD
THEORY:
               Using the accumulator, Multiplication is performed and the result is stored.
             Immediate addressing is employed.
             The MUL instruction writes the result in the accumulator
INPUT:
               MOV A,# 06H
               MOV F0,#02H
OUTPUT:
             8600         0CH
PROGRAM:
                                                                                         PS-8051
                        PANTECH PROLABS INDIA PVT.LTD
THEORY:
               Using the accumulator, Division is performed and the result is stored.
             Immediate addressing is employed.
             The div instruction writes the result in the accumulator
INPUT:
               MOV A,# 08H
               MOV F0,#02H
OUTPUT:
             8600         04H
             8601         00H
PROGRAM:
25
                                                PS – 8051 USER MANUAL
                                                                                         PS-8051
                        PANTECH PROLABS INDIA PVT.LTD
THEORY:
INPUT:
               8600      02H
               8601      03H       (FIRST INPUT)
               8602      04H
               8610      02H
               8611      03H       (SECOND INPUT)
               8612      04H
OUTPUT:
               8700      04H
               8701      06H
               8702      08H
26
                                                PS – 8051 USER MANUAL
                                                                                          PS-8051
                    PANTECH PROLABS INDIA PVT.LTD
PROGRAM:
27
                                        PS – 8051 USER MANUAL
                                                                  PS-8051
                        PANTECH PROLABS INDIA PVT.LTD
THEORY:
   Let Internal memory location (say 40H) has the biggest number i.e. zero.
   Now the biggest number in internal memory location is stored in memory as the Result.
   Now compare the first number with internal memory location. If it is greater, move it to
    internal memory
INPUT:
             8600         05H, 09H, 06H, 05H, 03H
             8605         07H, 0AH, 0BH, 7FH ,04H
OUTPUT:
               860A       7FH
PROGRAM:
                                                                       PS-8051
                        PANTECH PROLABS INDIA PVT.LTD
THEORY:
   The sorting technique used here is relatively simple. First consider the first two numbers of the array.
INPUT:
             8600          05H, 08H, 07H, 06H, 04H
OUTPUT:
               8600       04H, 05H, 06H, 07H, 08H
PROGRAM:
29
                                               PS – 8051 USER MANUAL
                                                                                        PS-8051
                         PANTECH PROLABS INDIA PVT.LTD
   8 bit two digit BCD number system into Hexadecimal number system.
   Binary coded decimal (BCD) is a system of writing numerals that assigns a four-digit binary code
       to each digit 0 through 9 in a decimal (base-10) numeral.
INPUT:
             8600          15H
OUTPUT:
               8601        0FH
PROGRAM:
                                                                             PS-8051
                          PANTECH PROLABS INDIA PVT.LTD
   8 bit two digit Hexadecimal number system into BCD number system.
   The hexadecimal number system (also called base-16) is a number system that uses 16 unique
    symbols to represent a particular value. Those symbols are 0-9 and A-F.
INPUT:
             8600           0FH
OUTPUT:
               8601         00H
               8602         15H
PROGRAM:
31
                                               PS – 8051 USER MANUAL
                                                                         PS-8051
                        PANTECH PROLABS INDIA PVT.LTD
THEORY:
   8 bit two digit ASCII l number system into hex decimal number system.
   Acronym for the American Standard Code for Information Interchange. Pronounced ask-ee, ASCII
    is a code for representing English characters as numbers, with each letter assigned a number from
    0 to 127
INPUT:
             8600          0AH
OUTPUT:
               8700        41H
PROGRAM:
32
                                              PS – 8051 USER MANUAL
                                                                              PS-8051
                        PANTECH PROLABS INDIA PVT.LTD
      A square root of a number a is a number y such that y2 = a, or, in other words, a number y whose
        square (the result of multiplying the number by itself, or y × y) is a.[1] For example, 3 is a square
        root of 09 because 32 = 09.
      8 bit square root number for follows
INPUT:
             8600         09H
OUTPUT:
               8700       03H
PROGRAM:
                                                                                     PS-8051
                        PANTECH PROLABS INDIA PVT.LTD
THEORY:
   Even parity bit and odd parity bit. When using even parity, the parity bit is set to 1
INPUT:
               8600       02H, 04H,06H, 08H
OUTPUT:
               8700       01H
PROGRAM:
34
                                               PS – 8051 USER MANUAL
                                                                                  PS-8051
                       PANTECH PROLABS INDIA PVT.LTD
THEORY:
    Assume XTAL = 11.0592 MHz, find the frequency of the square wave generated on pin P1.0 in the
     following program
    In mode 2 we do not need to reload TH since it is auto-reload. Now (256 - 05) × 1.085 us =251 ×
     1.085 us = 272.33 us is the high portion of the pulse.
    Since it is a 50% duty cycle square wave, the period T is twice that; as a result T = 2 × 272.33 us =
     544.67 us and the frequency =1.83597 kHz
PROCEDURE:
    Execute the program. Output generate the square wave J4 connector P1.0 in terminated
PROGRAM:
                                                                                    PS-8051
                       PANTECH PROLABS INDIA PVT.LTD
THEORY:
 8051 to transfer the letter “A” serially at 9600 baud continuously. Use 8-bit data and 1 stop bit.
PROCEDURE:
    Through open the PC hyper terminal window (serial window) .set 9600 BUAD RATE
    PS2 KIT press ‘B’ set 9600 baud rate value after execution program.
TRANSMITTER PROGRAM:
 36
                                            PS – 8051 USER MANUAL
                                                                                     PS-8051
                    PANTECH PROLABS INDIA PVT.LTD
RECEIVER PROGRAM:
                                                           PS-8051
                       PANTECH PROLABS INDIA PVT.LTD
Procedure:
1. Connect the two microcontroller kit using RS232 cable
2. Enter the transmitter program in 1ST microcontroller kit & receiver program in 2nd
microcontroller kit.
3. First run the receiver program in kit2 and then run the transmitter program in kit1.
4. After executing the transmitter program, reset the kit and go to location 8700h
5. The transferred data’s “yes” (ASCII) value are stored from 8400h onwards in the kit2.
 38
                                         PS – 8051 USER MANUAL
PS-8051