Você está na página 1de 87

Contents

CHAPTER 1: INTRODUCTION .............................................5


1. WELCOME ...................................................................5
1.2 PS 8051 BOARD OVERVIEW ...................................6
1.3 PS 8051 SPECIFICATIONS .......................................7
CHAPTER 2: SYSTEM DESCRIPTION ................................9
2.1 HARDWARE ...............................................................9
2.2 MAPPING OF DEVICES.............................................11
2.2.1 CONNECTOR DETAILS ........................................11
2.3 POWER SUPPLY DETAILS .........................................16
2.4 KEYBOARD DETAILS.................................................16
CHAPTER 3 COMMANDS AND KEYS .............................17
3.1 RESET ......................................................................17
3.2 H (Help Menu) ........................................................17
CHAPTER 4 OPERATING INSTRUCTIONS.......................18
4.1 POWER ON ..............................................................18
4.2 PROGRAM ENTRY USING ASSEMBLER: ...................19
4.3 ENTERING MNEMONICS .........................................20
4.4 DISASSEMBLER ........................................................24
Join the Technical Community Today!
http://www.pantechsolutions.net

4.5 M (MODIFY EXTERNAL MEMORY): .........................26


4.6 G (GO COMMAND) .................................................28
4.7 B (BAUD RATE) ........................................................29
4.8 R (REGISTER DISPLAY/MODIFY) ..............................30
4.9 I (Modify internal memory) ....................................33
4.10 T (TRANSFER COMMAND) ....................................33
4.11 N (LOCAL MODE)...................................................35
4.12 E (EXAMINE / DUMP MEMORY)............................35
4.13 PROGRAMMING THE 8051 TRAINER KIT: .............36
PROCEDURE 1: TO ENTER THE MNEMONICS ................36
PROCEDURE 2: TO ENTER THE OPCODE .....................37
CHAPTER 5 PROGRAMMING DETAILS ..........................40
5.1 REGISTERS: ..............................................................40
5.2 MONITOR PROGRAM: .............................................41
5.3 BREAKPOINT: ..........................................................42
CHAPTER 6: EXAMPLE PROGRAMS .................................44
6.1 32 BIT ADDITION ..................................................44
6.2 32 BIT SUBTRACTION ..............................................47
6.3 32 BIT BCD ADDITION .............................................49
6.4 FIBONACCI SERIES ...................................................52
Join the Technical Community Today!
http://www.pantechsolutions.net

6.5 HEX TO ASCII CONVERSION ....................................54


6.6 PORT BITS SELECTION .............................................56
6.7 CHARACTER TRANSMISSION ...................................58
6.8) ADDITIONAL PROGRAMS ON 8051 TRAINER KIT ...60
1. 8-BIT ADDITION: .....................................................60
2. 8-BIT SUBTRACTION: ..............................................61
4. SETTING BITS IN AN 8-BIT NUMBER: ......................62
5. MASKING BITS IN AN 8-BIT NUMBER: ....................63

Join the Technical Community Today!


http://www.pantechsolutions.net

CHAPTER 1: INTRODUCTION
1. WELCOME

Thank you for purchasing PS-8051 Board from


Pantech Solutions 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.

The PS-8051 Board Kit comes with the following:


1) PS-8051 Board
2) Sample device (NXP 89V51RD2)
3) Cross cable (RS232)
4) CD-ROM, which contains:
Sample programs
User and Technical Reference Manual
5) User and Technical Reference Manual
6) Keyboard (101 keys)
Join the Technical Community Today!
http://www.pantechsolutions.net

Note: If you are missing any part of the kit, please


contact our support executive
1.2 PS 8051 BOARD OVERVIEW

The PS 8051 board in based on Intel 8051


Microcontroller which operates at 11.0592 MHZ. the
board can operate using the 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
Join the Technical Community Today!
http://www.pantechsolutions.net

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.

1.3 PS 8051 SPECIFICATIONS


The PS 8051 board has the following hardware
features:

1. 8051 Microcontroller operating at 11.0592MHZ.


2. 32KB powerful software monitor in 27C256
EPROM.
3. 64KB on chip Flash memory (partially used by
Firmware).
4. Two 16 bit programmable on chip Timer.
5. 30 Programmable I/O pins (24 from 8255 and 6
(P1.0 to P1.5) from Port 1 of 8051).
6. 50 pin FRC connector for system bus expansion.
Join the Technical Community Today!
http://www.pantechsolutions.net

7. 20 pin FRC connector for user interface from


8255.
8. 9 pin D type connector for RS 232C interface.
9. Six different selectable baud rates from 150 to
9600.
10. One timer and external interrupt.
11. 101 PC type keyboard for entering user
address/data and for commands.
12. Built in line by line Assemble and
Disassemble.
13. User friendly software monitor for loading and
executing programs with break point facility.
14. Facility to connect to PC.
15. PS-8051 board supports Assembly and C
language

Join the Technical Community Today!


http://www.pantechsolutions.net

CHAPTER 2: SYSTEM DESCRIPTION


2.1 HARDWARE
PS 8051 Microcontroller board designed around
8051 is ideal for learning about Microcontroller. The
Microcontroller operates at 10 MHZ using a 11.0592
MHZ crystal. Lower bytes of address and data are
multiplexed as in 8085 and hence a decoder is necessary
to separates address and data. IC 74LS373 is used for
this purpose.

Firmware is stored in 27C256 EPROM. User


data/program can be stored in 32KB COMS static RAM of
type 62256. The board uses an 8255 totally available to
the user.

2X16 character LCD display is directly connected to the


bus like a memory device. Serial communication is
Join the Technical Community Today!
http://www.pantechsolutions.net

achieved using 8051. This is possible when the


Microcontroller is operating in alternate mode. In this
mode, port pins 3.0 and 3.1 act as receive and transmit
pins respectively.

Timer 1 is used for generating the baud clock. IC Max 232


convert TTL transmit and receive signals to RS 232 levels.

These signals are brought to a 9 pin D type connector


(female). 8051 has built in 16 bit counter/timer called
timer 0 and 1.

Timer 1 is used internally by the system for generating


the baud clock. Timer 0 is free and hence can be used by
the user.

8051 has following interrupt:


Timer 0 and 1 interrupts.
Join the Technical Community Today!
http://www.pantechsolutions.net

External interrupts 0 and 1.


Serial interrupt.

Out of the 5 interrupts listed above external interrupt 0


and timer 0 are available to the user.

2.2 MAPPING OF DEVICES

2.2.1 CONNECTOR DETAILS

1) 50 PIN EXPANSION CONNECTOR :

Join the Technical Community Today!


http://www.pantechsolutions.net

The 50 Pin FRC connector is used to interconnect with


the Interface cards like 8255, 8279, 8253/8251,8259,
8257 and the pin details are given below

Join the Technical Community Today!


http://www.pantechsolutions.net

2) 20 PIN EXPANSION CONNECTORS :


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

Join the Technical Community Today!


http://www.pantechsolutions.net

3) KEYBOARD CONNECTOR :

Join the Technical Community Today!


http://www.pantechsolutions.net

4) 9PIN D TYPE (FEMALE) :

5) LCD CONNECTOR

Join the Technical Community Today!


http://www.pantechsolutions.net

2.3 POWER SUPPLY DETAILS


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

2.4 KEYBOARD DETAILS


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).

Join the Technical Community Today!


http://www.pantechsolutions.net

CHAPTER 3 COMMANDS AND KEYS

3.1 RESET
This key is located in the main PS board. On depressing
this key the program starts executing from the beginning
i.e. at reset address 0000. On power on reset message PS
8051 is displayed in local LCD display.

3.2 H (Help Menu)


This key is used in PS 51/31 to get into help menu and
it will display the following commands.

Join the Technical Community Today!


http://www.pantechsolutions.net

CHAPTER 4 OPERATING INSTRUCTIONS


4.1 POWER ON
Connect the PS 8051 board to the power having the
following specifications.
+9V DC 1 Amp

Join the Technical Community Today!


http://www.pantechsolutions.net

Switch on the power supply after ensuring the correct


voltages. Following message will appear on the LCD
display.

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.

4.2 PROGRAM ENTRY USING ASSEMBLER:


PS 8051 is ready to accept the assembler entry
command after power on or after reset. Commands can
be entered in the second line of display and to enter into
assembler from where the user program gets stored.

Join the Technical Community Today!


http://www.pantechsolutions.net

In PS 8051, the user may enter the program from


8000H FFFFH (if 32KB RAM is installed).

EXAMPLE:
A8500

Press ENTER Key

On typing this line PS-8051B is ready to store the user


program from start address 1100. Following message
shows in local LCD.

4.3 ENTERING MNEMONICS


As mentioned before, each instruction of Microcontroller
can be entered by specific set of characters generally
2/3/4 letters followed by respective operands.
List of instruction and mnemonics are given in the
Appendix A.
Join the Technical Community Today!
http://www.pantechsolutions.net

EXAMPLE:
MOV A, R0 (ENTER key =

Sequence for entering the above instruction is as follows.


Typing sequence,

M
O
V
Space bar
A
,
R
0
Enter key

EXAMPLE:

INC A

Press ENTER Key


Join the Technical Community Today!
http://www.pantechsolutions.net

Typing sequence,
I
N
C
Space bar
A
Enter key (ENTER Key

As per the above procedure mnemonics are entered. On


completion of one line address, display in the first line
automatically gets incremented by respective value
depending on the instruction.

Line by line assembler converts the entered mnemonics


to equivalent opcode and stores it in the displayed
address. If any wrong mnemonics or operands are
entered ERROR message is displayed.

Join the Technical Community Today!


http://www.pantechsolutions.net

On completion of one line of entry, the user may repeat


the above sequence of operation till the program is over
or till the end of memory. Termination of Assembler
entry is by depressing enter key.

IMPORTANT INSTRUCTIONS

1. When immediate addressing mode is used before


entering the data, # symbol should be entered for
instruction like,
MOV A, #12
MOV DPTR, #1234
2. When register indirect addressing mode is used @
symbol to entered for instruction like,

MOV A, @DPTR
MOV A, @R0

Join the Technical Community Today!


http://www.pantechsolutions.net

EDITING

During the entry of mnemonics if any wrong entry is


made it is possible to edit it before depressing Enter key.
Use the Backspace key in the keyboard to erase the
previous character and this process may be repeated till
the first character. Once a character is erased, retype the
correct character.

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:

Join the Technical Community Today!


http://www.pantechsolutions.net

Assume the following data is stored in the memory


address 8500.

To disassemble the above data is,


D8500 [Enter]
On completion of this command, the display is as follows,
8500

74 AA

MOV A, #AA

To see the next line depress space bar key. Display is,
8502

00

NOP

In similar manner, the above sequence may be repeated


and depressing the enter key can terminate this
command.

Join the Technical Community Today!


http://www.pantechsolutions.net

4.5 M (MODIFY EXTERNAL MEMORY):


Using this command the user can display/modify any
external memory address.

ENTERING ADDRESS
After depressing this key, the system is ready to accept
from the keyboard and the board displays the data of the
selected memory address. Depressing any other non-hex
key results in error and the current command and once
again waits for new command.
ENTERING DATA
Now, if required, entering the new data can modify data
at the desired address. Entry of data is also similar to that
of address. Terminator for data is cursor up key or cursor
down key or space or enter key. Thus it is possible to load
the opcode/data in memory and verify it using M
(MDFY), UP and DOWN keys.
Join the Technical Community Today!
http://www.pantechsolutions.net

EXAMPLE:

Thus it is possible to load the program/data in memory


and verify it using M (MDFY), UP and DOWN key.

Join the Technical Community Today!


http://www.pantechsolutions.net

4.6 G (GO COMMAND)

This command is used to execute user program from the


specified address.

EXAMPLE:

EXAMPLE:
G8850

Join the Technical Community Today!


http://www.pantechsolutions.net

The above command starts the program execution from


address 8850. If enter key is depressed immediately after
G, the program starts executing from the value specified
in PC of R command. Thus all register values displayed in
R command are initial values for user program address.
4.7 B (BAUD RATE)
When this key is depressed it displays the currently
selected baud rate. Default baud rate is 2400 baud and
this will be selected during power on or hardware reset
and displayed in the first line. Second line display shows
150 baud. By depressing the space bar key the baud
display can be changed from 150 to 300 and so on till
9600. The system permits following baud rates.
{9600 2400 1200 600 300 and 150}
By depressing the enter key, the currently displayed baud
rate is selected fir future serial communication
(however,this will be modified if reset key is depressed).
Join the Technical Community Today!
http://www.pantechsolutions.net

NOTE: Space bar key doesnt select the baud rate and its
used to display the succeeding baud value only.
4.8 R (REGISTER DISPLAY/MODIFY)
When this key is depressed it displays current register
contents one after another. After depressing this key the
board waits for the register number and enter key from
the user.

If for example, key R2 depressed and then enter key the


system will display R2 contents.

As in the case of Modify, it is possible change the


displayed register contents. The entry is similar to that of
data filed entry. The termination for register data entry is
by space bar key.

Join the Technical Community Today!


http://www.pantechsolutions.net

Entering space bar key increments register number and


its data is displayed once again. Thus it is possible to
display and modify all the sixteen registers. Termination
of this command is by enter key.
EXAMPLE:

If after depressing R, A is typed followed by enter this


command displays A value and waits for the user to enter
new value.

Join the Technical Community Today!


http://www.pantechsolutions.net

If succeeding registers are to be modified use space key


to advance. Enter terminates the command. In the
following example, A register value to be changed to 33
and R0 to 66.
EXAMPLE:

Join the Technical Community Today!


http://www.pantechsolutions.net

4.9 I (Modify internal memory)


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 command


used to Modify the internal memory of controller.
4.10 T (TRANSFER COMMAND)
This command is useful for transferring data from one
area to another. The user has to specify the source start
address, source end address and Destination start
address.

Join the Technical Community Today!


http://www.pantechsolutions.net

User can key in source start address and its delimiter


with space bar key. Source end address is also keyed in
similar way with space bar key as delimiter.

Next enter the Destination start address and is moved


from one area to another.

EXAMPLE:

T9000 90FF 9800 Press ENTER Key.


The above command transfer the memory content
starting from source start address 9000 to destination
start address 9800 till source end address 90FF is
reached.
Starting address
End address
End address

9000
90FF
9800

Join the Technical Community Today!


http://www.pantechsolutions.net

4.11 N (LOCAL MODE)

When this key is depressed on PC keyboard, the PS


8051 Kit starts working through local 101 keyboard.
Serial communication is disabled. Following message will
appear in the LCD display.
! NORMAL MODE !

4.12 E (EXAMINE / DUMP MEMORY)


This command will show the hex byte on the console
from the memory. This command requires start address
and end address. Its operates only the serial mode.
EXAMPLE:

E8500 85FF This will show hex bytes in the location


from 8500 to 85FF.
Join the Technical Community Today!
http://www.pantechsolutions.net

4.13 PROGRAMMING THE 8051 TRAINER KIT:


PROCEDURE 1: TO ENTER THE MNEMONICS

1) Initially connect the 9V adaptor to J2 connector


2) Switch ON the PS-8051kit using slide Switch SW1
3) PANTECH- 8051 will be displayed on the LCD
4) Connect the Keyboard in PS/2 connector
5) Depress A starting address of the program for
Ex: A8500
For ex: A8500 enter key
Type the mnemonics MOV A,#12 press Enter key
Type the mnemonics ADD A,#12 press Enter key
and continue the same procedure till the end of
the Program

Join the Technical Community Today!


http://www.pantechsolutions.net

6) 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
7) To execute the program Depress G staring
address for Ex: G8500.
8) To see the result depress M result address for
Ex: M8600.
9) To view the output in the Register depress R and
press enter key in keyboard.

PROCEDURE 2: TO ENTER THE OPCODE


Follow the same procedure till step 4

Join the Technical Community Today!


http://www.pantechsolutions.net

1) Depress M starting address of the program for Ex:


M8500
For ex: M8500 press enter
Type the opcode 74 space bar
Type the opcode 12 space bar and continue the
same till the end of the program

2) 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
3) To execute the program Depress G staring
address for Ex: G8500.

Join the Technical Community Today!


http://www.pantechsolutions.net

4) To see the result depress M result address for


Ex: M8600.
5) 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

2) M is used to entering the Opcode.


3) M is used for entering the data.
Note: There are two ways to enter the program
1) Mnemonics method
2) Opcode method
Sample program is given to enter the program in both
the methods

Join the Technical Community Today!


http://www.pantechsolutions.net

CHAPTER 5 PROGRAMMING DETAILS


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 programmers 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.

Join the Technical Community Today!


http://www.pantechsolutions.net

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.
5.2 MONITOR PROGRAM:
Monitor the program uses following areas:
Program EPROM : 0000 7FFF
External user RAM

: 8000 8500 (for monitor

program variables).
Internal RAM

: 256 bytes RAM 128 bytes


used by 8051 itself. Area from
40 to 6F is available for user.
Join the Technical Community Today!
http://www.pantechsolutions.net

User Interrupts

: Timer 0 interrupt vectors to


address 800b.

External interrupt 0 vector to address 8003.


(The user has to enable desired interrupts in his
program).

Chip select signals for user:

CS6
CS7
CS8
CS9
CS10

4040 405F
4060 407F
4080 409F
40A0 40BF
40C0 40DF

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
Join the Technical Community Today!
http://www.pantechsolutions.net

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 are called all the
register values are saved and displayed on the console or
in local display.

BREAK POINT SUBROUTINE


ADDRESS 00BB

It is possible to continue the program execution just by


depressing G and enter in local mode.

BREAK POINT DISPLAY IN LOCAL MODE:

Join the Technical Community Today!


http://www.pantechsolutions.net

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.

BREAK POINT DISPLAY IN SERIAL MODE:

When break point is encountered, all the register values


are saved and all the register value will be displayed on
the console.
CHAPTER 6: EXAMPLE PROGRAMS
6.1 32 BIT ADDITION
FLOW CHART:

Join the Technical Community Today!


http://www.pantechsolutions.net

This program adds two 32 bit numbers.


First number is from 40h to 43h.
Second number is from 50h to 53h.
Result is from 60h to 63h.

NOTE: To enter the data in the internal memory, press


i and address then data.
Reset the kit and then enter, i0040

Press ENTER

Key.

Join the Technical Community Today!


http://www.pantechsolutions.net

Then enter the data and press space bar from


keyboard for entering the next data
EX: i0040
EX: i0050
EX: i0060

FIRST DATA
:
address : 40 TO 43 MSB IN 40
40
SECOND DATA : 50 address : 50 TO 53
MSB IN
50
RESULT DATA : 60 address : 60 TO 63
MSB IN
60

PROGRAM:
ADDRES
S
8500
8501

OPCODE MNEMONICS COMMENTS


C3
E5 43

CLR C
MOV A, 43

8503
8505
8507

35 53
F5 63
E5 42

ADDC A, 53
MOV 63,A
MOV A, 42

8509

35 52

ADDC A, 52

850B

F5 62

MOV 62, A

850D

E5 41

MOV A, 41

850F

35 51

ADDC A, 51

8511

F5 61

MOV 61, A

Clear Carry flag


Move the 1st LSB data from ADDR 43 to
ACC
Add ACC with 2nd LSB data in ADDR 53
Store the LSB data from ACC to ADDR 63
Move the 1st Mid Lowest data from ADDR
42 to ACC
Add ACC with 2nd Mid Lowest data in
ADDR 52
Store the Mid Lowest data from ACC to
ADDR 62
Move the 1st Mid Highest data from
ADDR 41 to ACC
Add ACC with 2nd Mid Highest data in
ADDR 51
Store the Mid Highest data from ACC to

Join the Technical Community Today!


http://www.pantechsolutions.net

8513

E5 40

MOV A, 40

8515
8517
8519

35 50
F5 60
12 00 BB

ADDC A, 50
MOV 60, A

ADDR 61
Move the 1st MSB data from ADDR 40 to
ACC
Add ACC with 2nd MSB data in ADDR 50
Store the MSB data from ACC to ADDR 60
LCALL 00BB Break point

6.2 32 BIT SUBTRACTION


FLOW CHART:

Join the Technical Community Today!


http://www.pantechsolutions.net

This program subtracts two 32 bit numbers.


First number is from 40h to 43h.
Second number is from 50h to 53h.
Result is from 60h to 63h.
NOTE: To enter the data in the internal memory, press
i and address then data.
Reset the kit and then enter, i0040

Press ENTER

Key.
Then enter the data and press space bar from
keyboard for entering the next data
EX: i0040
EX: i0050
EX: i0060

FIRST DATA : 40

address : 40 TO 43 MSB IN
40
SECOND DATA : 50 address : 50 TO 53 MSB IN
50
RESULT DATA : 60 address : 60 TO 63 MSB IN
60

PROGRAM:

Join the Technical Community Today!


http://www.pantechsolutions.net

6.3 32 BIT BCD ADDITION


FLOW CHART:

Join the Technical Community Today!


http://www.pantechsolutions.net

This program adds 32 bit BCD numbers.


First BCD number is from 40h to 43h.
Second BCD number is from 50h to 53h.
Result is from 60h to 63h.

Join the Technical Community Today!


http://www.pantechsolutions.net

NOTE: To enter the data in the internal memory, press


i and address then data.
For Example: Reset the kit and then enter, i0040 Press
ENTER Key.

PROGRAM:

Join the Technical Community Today!


http://www.pantechsolutions.net

6.4 FIBONACCI SERIES


FLOW CHART

FIBONACCI SERIES (0, 1, 1, 2, 3, 5, 8, 13 ..)


This program will generate the Fibonacci series
This will take input from the internal memory, 60h.
Join the Technical Community Today!
http://www.pantechsolutions.net

Input = number of elements to be generate in the


series.
Output =elements of the series is stored in the
memory.
Starting from 8F00h.

NOTE: To enter the data in the internal memory, press


i and address then data.

For Example: Reset the kit and then enter, i0060 Press
ENTER Key.

No = 40
Beg = 8F00

Input count location


Output buffer start address

Join the Technical Community Today!


http://www.pantechsolutions.net

PROGRAM:
ADDR
ESS
8500
8502
8504
8506
8508
850B

OPCOD
E
A8 60
79 01
7A 01
74 00
90 8F 00
B8 00 03

MNEMONICS

COMMENTS

MOV R0, 60
MOV R1, #01
MOV R2, #01
MOV A, #00
MOV DPTR,#8F00
CJNE R0, #00, 8511

850E
8511
8512
8513
8514
8515
8518
8519
851A

02 85 1C
F0
A3
FA
29
85 02 01
F0
A3
D8 F7

LJMP 851C
MOVX @DPTR, A
INC DPTR
MOV R2, A
ADD A, R1
MOV R1,R2
MOVX @DPTR, A
INC DPTR
DJNZ R0, 8513

851C

12 00 BB LCALL 00BB

Move the no. of Fibonacci data into R0


Initialize 1 to R1
Initialize 1 to R2
Initialize 0 to ACC
Load output data to DPTR
If R0 is not equal to 0 then jump into
8511
Long Jump into 851C
Store ACC value into DPTR
Increment the DPTR
Load the ACC value into R2
Add ACC with R1
Copy value from R2(addr2) to R1 (addr1)
Store the new value from ACC to DPTR
Increment DPTR
If the count isnt equal to Zero, jump
back
Break point address

6.5 HEX TO ASCII CONVERSION

Join the Technical Community Today!


http://www.pantechsolutions.net

This program takes one HEX number (0 to F) then it will


convert that in to ASCII byte.user has entered any one of
the HEX number ( 0 to F).

Join the Technical Community Today!


http://www.pantechsolutions.net

INPUT : Enter the HEX value in external memory


location 8600.
OUTPUT : Result is stored in Accumulator and also in
R1 register.
PROGRAM:

6.6 PORT BITS SELECTION


FLOW CHART:

Join the Technical Community Today!


http://www.pantechsolutions.net

In this port -1bit (p1.0) is set and cleared after


specific interval
Using bit wise operators
User can view the output on the first pin of 8051(i.e.,
bit 0 of port1) in oscilloscope.
PROGRAM:

Join the Technical Community Today!


http://www.pantechsolutions.net

6.7 CHARACTER TRANSMISSION


Baud calculation

Baud rate = (1/32) *


(OSCILATOR FREQ/
(12*256))

Join the Technical Community Today!


http://www.pantechsolutions.net

0089
equ
008d
equ
008b
equ
088e
equ
0098
equ
0099
equ

= tmod:
89h
= th1:
8dh
= tl1:
8bh
= tr1:
8eh
= scon:
98h
= sbuf
99h

PROGRAM:

Join the Technical Community Today!


http://www.pantechsolutions.net

OUTPUT: connect the Cross cable between PC and KIT


execute the program and verify the result in
HyperTerminal
6.8) ADDITIONAL PROGRAMS ON 8051 TRAINER KIT
EX1 programming using Arithmetic, Logical and Bit
Manipulation instruction of 8051
1. 8-BIT ADDITION:

INPUT:
8501 = 12
8503 = 12
RESULT:
8600 = 24.

Join the Technical Community Today!


http://www.pantechsolutions.net

2. 8-BIT SUBTRACTION:

INPUT:
8501 = 20
8503 = 10
RESULT:
8600 = 10.
3. 8-BIT MULTIPLICATION:

Join the Technical Community Today!


http://www.pantechsolutions.net

INPUT:
8501 = 0A
8504 = 88
RESULT:
8600 = 50 (LSB)
8601 = 05 (MSB)
4. SETTING BITS IN AN 8-BIT NUMBER:

INPUT:
8501 = 2F
8503 = 45
RESULT:
8600 = 6F.
Join the Technical Community Today!
http://www.pantechsolutions.net

5. MASKING BITS IN AN 8-BIT NUMBER:

INPUT:
8501 = 87
8503 = 7E
RESULT:
8600 = 06.
1) 16-BIT ADDITION of two numbers:

OBJECTIVE:

To perform 16-bit addition of two 16-bit data using


indirect addressing and store the result in Memory.

Join the Technical Community Today!


http://www.pantechsolutions.net

THEORY:

As there is only one 16-bit Register in 89C51, 16-bit


addition is performed by using ADDC Instruction twice,
i.e. adding LSB first and MSB next.

GIVE INPUT TO THIS LOCATION:

8500 - F5; MSB of first 16 bit data

8501 - D5; LSB of

first 16 bit data


8502 - 43; MSB of second 16 bit data

8503 - 55; LSB of

second 16 bit data

RESULT:

8600 - MSB of result

8601 - LSB of result

PROGRAM
Join the Technical Community Today!
http://www.pantechsolutions.net

PROCEDURE
1. Enter the input data in memory location 8500 to 8503.
2. Enter the above opcodes from 8500.
3. Execute the program.
4. Result stored in 8600 & 8601. Change data and check
result in 8600, 8601.

Join the Technical Community Today!


http://www.pantechsolutions.net

2) 16-BIT SUBTRACTION Of Two Numbers:


OBJECTIVE:

To perform 16-bit Subtraction of two 16-bit data using


indirect addressing and store the result in memory.

THEORY:

As there is only one 16-bit Register in 89C51, 16-bit


subtraction is performed by using subb Instruction.

GIVE INPUT TO THIS LOCATION:

8600 - MSB of first operand

8601 - MSB of second


operand

8602 - LSB of first operand

8603 - LSB of second


operand

Join the Technical Community Today!


http://www.pantechsolutions.net

RESULT:
8700 MSB

8701 LSB

PROCEDURE
1. Enter the input data in memory location 8600 to 8603.
Join the Technical Community Today!
http://www.pantechsolutions.net

2. Enter the above opcodes from 8500.


3. Execute the program.
4. Result stored in 8700 & 8701. Change data and check
result in 8700, 8701.
3) 8-BIT MULTIPLICATION of two numbers:
OBJECTIVE:

To perform 8-bit Multiplication of two 8-bit data using


indirect addressing and store the result In memory.

THEORY:

Using indirect addressing Multiply two 8-bit data.

GIVE INPUT TO THIS LOCATION:

8600 - Multiplicand
Join the Technical Community Today!
http://www.pantechsolutions.net

8601 - Multiplier

RESULT:

8700

PROCEDURE
1. Enter the input data in memory location 8600 to 8601.
2. Enter the above opcodes from 8500.
3. Execute the program.

Join the Technical Community Today!


http://www.pantechsolutions.net

4. Result stored in 8700 & 8701. Change data and check


result in 8700, 8701.
4) 8-BIT DIVISION of two numbers:
OBJECTIVE:

To perform 8-bit Division of two 8-bit data using indirect


addressing and store the result in memory.

THEORY:

Using indirect addressing divide two 8-bit datas.

GIVE INPUT TO THIS LOCATION:


8600 - Dividend.
8601 - Divisor.
RESULT:
8700 & 8701
Join the Technical Community Today!
http://www.pantechsolutions.net

PROGRAM

PROCEDURE
1. Enter the input data in memory location 8600 to 8601.
2. Enter the above opcodes from 8500.
3. Execute the program.
4. Result stored in 8700 & 8701. Change data and check
result in 8700, 8701
5) FACTORIAL OF A GIVEN NUMBER:
OBJECTIVE:
Join the Technical Community Today!
http://www.pantechsolutions.net

To find factorial of a given number.

PROGRAM

PROCEDURE

Join the Technical Community Today!


http://www.pantechsolutions.net

1. Enter the input data in memory location 8600.


2. Enter the above opcodes from 8500.
3. Execute the program.
4. Result stored in 8600. Change data and check result in
8600.
6) MULTIPLY BY SHIFT AND ADD METHOD
OBJECTIVE:
Multiple of two 8-bit numbers using repeat addition
method.

PROGRAM

Join the Technical Community Today!


http://www.pantechsolutions.net

Join the Technical Community Today!


http://www.pantechsolutions.net

MEMORY DDRESS OPCODES

MNEMONICS

8500
8503
8504
8505
8508
8509
850A
850C
850E
850F
8511
8512
8515
8516
8517
8518
8519
851A
851B
851C
851D
851E
8520
8523
8524
8525

MOV DPTR,#8600H
MOVX A,@DPTR
MOV R0,A
MOV DPTR,#8601H
MOVX A,@DPTR
MOV R1,A
MOV R2,#00H
MOV R3,#08H
LOOP: MOV A,R1
ANL A,#01H
MOV R4,A
CJNE R4,#01H,LOOP1
MOV A,R2
ADD A,R0
MOV R2,A
LOOP1: MOV A,R0
RL A
MOV R0,A
MOV A,R1
RR A
MOV R1,A
DJNZ R3,LOOP
MOV DPTR,#8700H
MOV A,R2
MOVX @DPTR,A
E:
SJMP E

90 86 00
E0
F8
90 86 01
E0
F9
7A 00
7B 08
E9
54 01
FC
BC 01 03
EA
28
FA
E8
23
F8
E9
03
F9
DB EE
90 87 00
EA
F0
80 FE

PROCEDURE
1. Enter the input data in memory location 8600 & 8601.
2. Enter the above opcodes from 8500.

Join the Technical Community Today!


http://www.pantechsolutions.net

3. Execute the program.


4. Result stored in 8700. Change data and check result in
8700.
7) LCM of a given number
OBJECTIVE
To find LCM of a given number.
PROGRAM
ORG 8500H
MEMORY
8500
8503
8504
8505
8508
8509
850A
850C
850E
850F
8510
8511
8513
8514
8515
8517
8518
851A
851B

ADDRESS OPCODES
90 86 00
E0
F8
90 86 01
E0
F9
7D 00
7A 01
C3
EA
98
60 1B
EA
99
60 17
E8
8A F0
84
E5 F0

MNEMONICS
MOV DPTR,#8600H
MOVX A,@DPTR
MOV R0,A
MOV DPTR,#8601H
MOVX A,@DPTR
MOV R1,A
MOV R5,#00H
MOV R2,#01H
TOP1: CLR C
MOV A,R2
SUBB A,R0
JZ TOPY
MOV A,R2
SUBB A,R1
JZ TOPY
MOV A,R0
MOV B,R2
DIV AB
MOV A,B

Join the Technical Community Today!


http://www.pantechsolutions.net

851D
8520
8521
8523
8524
8526
8529
852A
852B
852C
852E
852F
8532
8533

B4 00 0B
E9
8A F0
84
E5 F0
B4 00 02
EA
FD
0A
80 E0
ED
90 87 00
F0
80 FE

CJNE A,#00H,TOPX
MOV A,R1
MOV B,R2
DIV AB
MOV A,B
CJNE A,#00H,TOPX
MOV A,R2
MOV R5,A
TOPX: INC R2
SJMP TOP1
TOPY: MOV A,R5
MOV DPTR,#8700H
MOVX @DPTR,A
E:
SJMP E

PROCEDURE
1. Enter the input data in memory location 8600 & 8601.
2. Enter the above opcodes from 8500.
3. Execute the program.
4. Result stored in 8700. Change data and check result in
8700
8) HCF of a given number
OBJECTIVE
To find HCF of a given number.

Join the Technical Community Today!


http://www.pantechsolutions.net

PROGRAM
ORG 8500H

PROCEDURE
Join the Technical Community Today!
http://www.pantechsolutions.net

1. Enter the input data in memory location 8600 & 8601.


2. Enter the above opcodes from 8500.
3. Execute the program.
4. Result stored in 8700 & 8701. Change data and check
result in 8700 & 8701.
9) MATRIX ADDITION
PROGRAM
ORG 8500H
MEMORY ADDRESS
OPCODES
8500
90 86 00
8503
E0
8504
F5 F0
8506
90 86 50
8509
E0
850A
25 F0
850C
90 87 00
850F
F0
8510
90 86 01
8513
E0
8514
F5 F0
8516
90 86 51
8519
E0
851A
25 F0
851C
90 87 01
851F
F0

MNEMONICS
MOV DPTR,#8600H
MOVX A,@DPTR
MOV B,A
MOV DPTR,#8650H
MOVX A,@DPTR
ADD A,B
MOV DPTR,#8700H
MOVX @DPTR,A
MOV DPTR,#8601H
MOVX A,@DPTR
MOV B,A
MOV DPTR,#8651H
MOVX A,@DPTR
ADD A,B
MOV DPTR,#8701H
MOVX @DPTR,A

Join the Technical Community Today!


http://www.pantechsolutions.net

8523
8524
8526
8529
852A
852C
852F
8530
8533
8534
8536
8539
853A
853C
853F
8540

E0
F5 F0
90 86 52
E0
25 F0
90 87 02
F0
90 86 03
E0
F5 F0
90 86 53
E0
25 F0
90 87 03
F0
80 FE

E:

MOVX A,@DPTR
MOV B,A
MOV DPTR,#8652H
MOVX A,@DPTR
ADD A,B
MOV DPTR,#8702H
MOVX @DPTR,A
MOV DPTR,#8603H
MOVX A,@DPTR
MOV B,A
MOV DPTR,#8653H
MOVX A,@DPTR
ADD A,B
MOV DPTR,#8703H
MOVX @DPTR,A
SJMP E

PROCEDURE
1. Enter the input data in memory location 8600 & 8603.
2. Enter the above opcodes from 8500.
3. Execute the program.
4. Result stored from 8700 & 8703.Change data and
check result in 8700 & 8703
10) FIBONACCI SERIES OF A NUMBER
OBJECTIVE:
Join the Technical Community Today!
http://www.pantechsolutions.net

To find Fibonacci series of a given number.


PROGRAM

PROCEDURE
1. Enter the input data in memory location 8600.
2. Enter the above opcodes from 8500.
3. Execute the program.
4. Result stored from 8601 . Change data and check
result in 8601
Join the Technical Community Today!
http://www.pantechsolutions.net

11) SQUARE OF A GIVEN NUMBER


OBJECTIVE:
To find Square of a given number.
PROGRAM

12) SQUARE ROOT OF A GIVEN NUMBER


OBJECTIVE
To find Square root of a given number.
PROGRAM

Join the Technical Community Today!


http://www.pantechsolutions.net

PROCEDURE
1. Enter the input data in memory location 8600.
2. Enter the above opcodes from 8500.
3. Execute the program.
4. Result stored from 8700 . Change data and check
result in 8700

Join the Technical Community Today!


http://www.pantechsolutions.net

13) LARGEST ELEMENT IN AN ARRAY:


OBJECTIVE:
To find the biggest number in an array of 8-bit unsigned
numbers of predetermined length.
EXAMPLE:
The length of the array is specified in the Register R5. The
array itself starts at 8600. The largest number of the
array is stored at location 860A.
Data : [8600] = 05
[8601] = 67

[8602] = 76

[8603] = 89 [8604] = 98
[8605] = 49 [8606] = 45
[8607] = 9F [8608] = 57
[8609] = 7A
Result :[860A] = 9F

Join the Technical Community Today!


http://www.pantechsolutions.net

PROGRAM

Join the Technical Community Today!


http://www.pantechsolutions.net

Did you enjoy the read?


Pantech solutions creates information packed
technical documents like this one every month. And
our website is a rich and trusted resource used by a
vibrant online community of more than 1,00,000
members from organization of all shapes and sizes.

Join the Technical Community Today!


http://www.pantechsolutions.net

What do we sell?
Our
products
range
from
Various
Microcontroller development boards, DSP Boards,
FPGA/CPLD boards, Communication Kits, Power
electronics, Basic electronics, Robotics, Sensors,
Electronic components and much more . Our goal is
to make finding the parts and information you need
easier and affordable so you can create awesome
projects and training from Basic to Cutting edge
technology.

Join the Technical Community Today!


http://www.pantechsolutions.net

Você também pode gostar