8051 trainer kit user and technical reference manual
TRANSCRIPT
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
1/87
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
2/87
Join the Technical Community Today!
http://www.pantechsolutions.net
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 ............................. 173.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
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
3/87
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) ............................ 354.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
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
4/87
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
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
5/87
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)
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
6/87
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
7/87
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.
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
8/87
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
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
9/87
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
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
10/87
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 transmitpins 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.
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
11/87
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 :
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
12/87
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
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
13/87
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
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
14/87
Join the Technical Community Today!
http://www.pantechsolutions.net
3) KEYBOARD CONNECTOR :
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
15/87
Join the Technical Community Today!
http://www.pantechsolutions.net
4) 9PIN ‘D’ TYPE (FEMALE) :
5) LCD CONNECTOR
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
16/87
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).
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
17/87
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.
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
18/87
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
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
19/87
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 intoassembler from where the user program gets stored.
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
20/87
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.
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
21/87
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
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
22/87
Join the Technical Community Today!
http://www.pantechsolutions.net
Typing sequence,
I
NC
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.
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
23/87
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
24/87
Join the Technical Community Today!
http://www.pantechsolutions.net
EDITING
During the entry of mnemonics if any wrong entry ismade 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:
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
25/87
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.
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
26/87
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 wait’s 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.
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
27/87
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.
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
28/87
Join the Technical Community Today!
http://www.pantechsolutions.net
4.6 G (GO COMMAND)
This command is used to execute user program from thespecified address.
EXAMPLE:
EXAMPLE:
G8850
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
29/87
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 specifiedin 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).
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
30/87
Join the Technical Community Today!
http://www.pantechsolutions.net
NOTE: Space bar key doesn’t select the baud rate and it’s
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.
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
31/87
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. Terminationof 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.
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
32/87
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 33and R0 to 66.
EXAMPLE:
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
33/87
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.
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
34/87
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 9000 End address 90FF
End address 9800
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
35/87
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.
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
36/87
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 keyType 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
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
37/87
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
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
38/87
Join the Technical Community Today!
http://www.pantechsolutions.net
1) Depress “M” starting address of the program for Ex:
M8500
For ex: M8500 press enterType 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.
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
39/87
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’
andpress 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
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
40/87
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 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.
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
41/87
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 avalue 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.
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
42/87
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 4040 – 405F
CS7 4060 – 407F
CS8 4080 – 409F
CS9 40A0 – 40BF
CS10 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
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
43/87
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:
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
44/87
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 oneby 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:
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
45/87
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.
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
46/87
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 FIRST DATA :
40
address : 40 TO 43 MSB IN 40
EX: i0050 SECOND DATA : 50 address : 50 TO 53 MSB IN
50
EX: i0060 RESULT DATA : 60 address : 60 TO 63 MSB IN
60
PROGRAM:
ADDRES
S
OPCODE MNEMONICS COMMENTS
8500 C3 CLR C Clear Carry flag
8501 E5 43 MOV A, 43 Move the 1st LSB data from ADDR 43 to
ACC
8503 35 53 ADDC A, 53 Add ACC with 2nd LSB data in ADDR 53
8505 F5 63 MOV 63,A Store the LSB data from ACC to ADDR 63
8507 E5 42 MOV A, 42 Move the 1st Mid Lowest data from ADDR
42 to ACC
8509 35 52 ADDC A, 52 Add ACC with 2nd Mid Lowest data in
ADDR 52
850B F5 62 MOV 62, A Store the Mid Lowest data from ACC to
ADDR 62
850D E5 41 MOV A, 41 Move the 1st Mid Highest data from
ADDR 41 to ACC
850F 35 51 ADDC A, 51 Add ACC with 2nd Mid Highest data in
ADDR 51
8511 F5 61 MOV 61, A Store the Mid Highest data from ACC to
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
47/87
Join the Technical Community Today!
http://www.pantechsolutions.net
ADDR 61
8513 E5 40 MOV A, 40 Move the 1st MSB data from ADDR 40 to
ACC
8515 35 50 ADDC A, 50 Add ACC with 2nd MSB data in ADDR 50
8517 F5 60 MOV 60, A Store the MSB data from ACC to ADDR 60 8519 12 00 BB LCALL 00BB Break point
6.2 32 BIT SUBTRACTION
FLOW CHART:
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
48/87
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 FIRST DATA : 40 address : 40 TO 43 MSB IN40
EX: i0050 SECOND DATA : 50 address : 50 TO 53 MSB IN
50
EX: i0060 RESULT DATA : 60 address : 60 TO 63 MSB IN
60
PROGRAM:
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
49/87
Join the Technical Community Today!
http://www.pantechsolutions.net
6.3 32 BIT BCD ADDITION
FLOW CHART:
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
50/87
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.
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
51/87
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:
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
52/87
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.
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
53/87
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 thememory.
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 Input count location
Beg = 8F00 Output buffer start address
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
54/87
Join the Technical Community Today!
http://www.pantechsolutions.net
PROGRAM:
ADDR
ESS
OPCOD
E
MNEMONICS COMMENTS
8500 A8 60 MOV R0, 60 Move the no. of Fibonacci data into R0
8502 79 01 MOV R1, #01 Initialize 1 to R1
8504 7A 01 MOV R2, #01 Initialize 1 to R2
8506 74 00 MOV A, #00 Initialize 0 to ACC
8508 90 8F 00 MOV DPTR,#8F00 Load output data to DPTR
850B B8 00 03 CJNE R0, #00, 8511 If R0 is not equal to 0 then jump into
8511
850E 02 85 1C LJMP 851C Long Jump into 851C
8511 F0 MOVX @DPTR, A Store ACC value into DPTR
8512 A3 INC DPTR Increment the DPTR
8513 FA MOV R2, A Load the ACC value into R2
8514 29 ADD A, R1 Add ACC with R1
8515 85 02 01 MOV R1,R2 Copy value from R2(addr2) to R1 (addr1)
8518 F0 MOVX @DPTR, A Store the new value from ACC to DPTR
8519 A3 INC DPTR Increment DPTR
851A D8 F7 DJNZ R0, 8513 If the count isn’t equal to Zero, jump
back851C 12 00 BB LCALL 00BB Break point address
6.5 HEX TO ASCII CONVERSION
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
55/87
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
56/87
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 inR1 register.
PROGRAM:
6.6 PORT BITS SELECTION
FLOW CHART:
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
57/87
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:
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
58/87
Join the Technical Community Today!
http://www.pantechsolutions.net
6.7 CHARACTER TRANSMISSION
Baud calculation
Baud rate = (1/32) *
(OSCILATOR FREQ/
(12*256))
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
59/87
Join the Technical Community Today!
http://www.pantechsolutions.net
0089 = tmod:
equ 89h
008d = th1:
equ 8dh 008b = tl1:
equ 8bh
088e = tr1:
equ 8eh
0098 = scon:
equ 98h
0099 = sbuf
equ 99h
PROGRAM:
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
60/87
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.
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
61/87
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:
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
62/87
Join the Technical Community Today!
http://www.pantechsolutions.net
INPUT:
8501 = 0A8504 = 88
RESULT:
8600 = 50 (LSB)
8601 = 05 (MSB)
4. SETTING BITS IN AN 8-BIT NUMBER:
INPUT:
8501 = 2F
8503 = 45
RESULT:
8600 = 6F.
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
63/87
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.
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
64/87
Join the Technical Community Today!
http://www.pantechsolutions.net
THEORY:
As there is only one 16-bit Register in 89C51, 16-bitaddition 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
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
65/87
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 checkresult in 8600, 8601.
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
66/87
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
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
67/87
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.
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
68/87
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 checkresult 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
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
69/87
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.
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
70/87
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 data’s.
GIVE INPUT TO THIS LOCATION:
8600 - Dividend.
8601 - Divisor.
RESULT:
8700 & 8701
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
71/87
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:
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
72/87
Join the Technical Community Today!
http://www.pantechsolutions.net
To find factorial of a given number.
PROGRAM
PROCEDURE
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
73/87
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
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
74/87
Join the Technical Community Today!
http://www.pantechsolutions.net
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
75/87
Join the Technical Community Today!
http://www.pantechsolutions.net
MEMORY DDRESS OPCODES MNEMONICS
8500 90 86 00 MOV DPTR,#8600H
8503 E0 MOVX A,@DPTR
8504 F8 MOV R0,A
8505 90 86 01 MOV DPTR,#8601H8508 E0 MOVX A,@DPTR
8509 F9 MOV R1,A
850A 7A 00 MOV R2,#00H
850C 7B 08 MOV R3,#08H
850E E9 LOOP: MOV A,R1
850F 54 01 ANL A,#01H
8511 FC MOV R4,A
8512 BC 01 03 CJNE R4,#01H,LOOP1
8515 EA MOV A,R2
8516 28 ADD A,R0
8517 FA MOV R2,A
8518 E8 LOOP1: MOV A,R0
8519 23 RL A
851A F8 MOV R0,A
851B E9 MOV A,R1
851C 03 RR A
851D F9 MOV R1,A
851E DB EE DJNZ R3,LOOP
8520 90 87 00 MOV DPTR,#8700H
8523 EA MOV A,R2
8524 F0 MOVX @DPTR,A
8525 80 FE E: SJMP E
PROCEDURE
1. Enter the input data in memory location 8600 & 8601.
2. Enter the above opcodes from 8500.
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
76/87
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 ADDRESS OPCODES MNEMONICS
8500 90 86 00 MOV DPTR,#8600H
8503 E0 MOVX A,@DPTR
8504 F8 MOV R0,A
8505 90 86 01 MOV DPTR,#8601H
8508 E0 MOVX A,@DPTR8509 F9 MOV R1,A
850A 7D 00 MOV R5,#00H
850C 7A 01 MOV R2,#01H
850E C3 TOP1: CLR C
850F EA MOV A,R2
8510 98 SUBB A,R0
8511 60 1B JZ TOPY
8513 EA MOV A,R2
8514 99 SUBB A,R1
8515 60 17 JZ TOPY
8517 E8 MOV A,R0
8518 8A F0 MOV B,R2
851A 84 DIV AB
851B E5 F0 MOV A,B
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
77/87
Join the Technical Community Today!
http://www.pantechsolutions.net
851D B4 00 0B CJNE A,#00H,TOPX
8520 E9 MOV A,R1
8521 8A F0 MOV B,R2
8523 84 DIV AB
8524 E5 F0 MOV A,B
8526 B4 00 02 CJNE A,#00H,TOPX8529 EA MOV A,R2
852A FD MOV R5,A
852B 0A TOPX: INC R2
852C 80 E0 SJMP TOP1
852E ED TOPY: MOV A,R5
852F 90 87 00 MOV DPTR,#8700H
8532 F0 MOVX @DPTR,A
8533 80 FE 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.
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
78/87
Join the Technical Community Today!
http://www.pantechsolutions.net
PROGRAM
ORG 8500H
PROCEDURE
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
79/87
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
MNEMONICS
8500 90 86 00 MOV DPTR,#8600H
8503 E0 MOVX A,@DPTR8504 F5 F0 MOV B,A
8506 90 86 50 MOV DPTR,#8650H
8509 E0 MOVX A,@DPTR
850A 25 F0 ADD A,B
850C 90 87 00 MOV DPTR,#8700H
850F F0 MOVX @DPTR,A
8510 90 86 01 MOV DPTR,#8601H
8513 E0 MOVX A,@DPTR
8514 F5 F0 MOV B,A
8516 90 86 51 MOV DPTR,#8651H
8519 E0 MOVX A,@DPTR
851A 25 F0 ADD A,B
851C 90 87 01 MOV DPTR,#8701H
851F F0 MOVX @DPTR,A
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
80/87
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
81/87
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
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
82/87
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
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
83/87
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
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
84/87
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
85/87
Join the Technical Community Today!
http://www.pantechsolutions.net
PROGRAM
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
86/87
Join the Technical Community Today!
http://www.pantechsolutions.net
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,000members from organization of all shapes and sizes.
Did you enjoy the read?
-
8/19/2019 8051 Trainer Kit User and Technical Reference Manual
87/87