42
Microprocessor and Interfacing Techniques (TE-380) Telecommunication Engineering Department Sir Syed University of Engineering & Technology 1 Laboratory Exercise 1(a) Objective: Introducing the BGC- 8088 Microprocessor training system. Salient features. Hardware specifications. Software architecture. Description: The BGC Micro-engineer V3.4 is a 8088 microprocessor training system. It contains hardware and software to expand its functions and applications. It provides user an inexpensive and useful learning tool for the 8088 microprocessor. Salient Features of BGC-8088 Micro-engineer V3.4 Trainer (i) Hardware: 8088-2 CPU, 4.77 MHz clock, with 8 MHz option. 8K SRAM and 16K EPROM with wired socket for additional 24K SRAM and 16K EPROM. 1MB RAM is optional. Keyboard: Large size, 56 alphanumeric and ASCII symbol keys. On-board LCD display. An external 80 x 24 monochrome monitor can be used with a Hercules card. Built in standard Centronics printer interface. RS-232 interface. Two IBM PC or compatible expansion slots. Status ports to display keyboard status as Caps Lock, Ins, and Ctrl-P. In addition, a speaker is built in for user application. Parallel control interfaces: Three 8-bit I/O ports(8255), three timers(8254), and five interrupt signals (8259A). An area on the main board is reserved for circuit designs and experiments. Switching power supply: +5V, +5V, +12V, +12V and GND. (ii) Software: 8088 assembler and dis-assembler. Assembly language coding. Memory commands. D-display, M-move, C-Compare, E-edit and F-fill. Display and / or modify the contents of registers.

Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

  • Upload
    lamcong

  • View
    271

  • Download
    4

Embed Size (px)

Citation preview

Page 1: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

1

Laboratory Exercise 1(a)Objective:

Introducing the BGC- 8088 Microprocessor training system. Salient features. Hardware specifications. Software architecture.

Description:

The BGC Micro-engineer V3.4 is a 8088 microprocessor training system. It contains hardwareand software to expand its functions and applications. It provides user an inexpensive and usefullearning tool for the 8088 microprocessor.

Salient Features of BGC-8088 Micro-engineer V3.4 Trainer

(i) Hardware:

8088-2 CPU, 4.77 MHz clock, with 8 MHz option.8K SRAM and 16K EPROM

with wired socket for additional 24K SRAM and 16K EPROM. 1MB RAM is

optional.

Keyboard: Large size, 56 alphanumeric and ASCII symbol keys. On-board LCD

display. An external 80 x 24 monochrome monitor can be used with a Hercules card.

Built in standard Centronics printer interface.

RS-232 interface.

Two IBM PC or compatible expansion slots.

Status ports to display keyboard status as Caps Lock, Ins, and Ctrl-P. In addition,

a speaker is built in for user application.

Parallel control interfaces: Three 8-bit I/O ports(8255), three timers(8254), and

five interrupt signals (8259A).

An area on the main board is reserved for circuit designs and experiments.

Switching power supply: +5V, +5V, +12V, +12V and GND.

(ii) Software:

8088 assembler and dis-assembler. Assembly language coding.

Memory commands. D-display, M-move, C-Compare, E-edit and F-fill.

Display and / or modify the contents of registers.

Page 2: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

2

Single step program execution and debug.

Breakpoint debug, for setting up to 10 breakpoints for program debugging.

Numerical systems conversions and calculations.

Download / Upload from / to external system.

RS-232 driver routine.

Keyboard driver routine.

Printer driver routine.

Hercules card driver routine.

LCD driver routine.

Hardware specifications of BGC-8088 Micro-engineer V3.4 Trainer

CPU: 8088-2 CPU runs at 4.77 MHz. However, a clock rate of 8 MHz can be achievedby using a 24 MHz crystal oscillator.

RAM: The system provides 32K RAM, addresses from 00000H to 07FFFH, with00000H to 00FFFH for system program and 0100H to 07FFFH for user applications.

ROM: The system provides ROM, addresses from F8000H to FFFFFH, withFC000H to FFFFFH for BIOS and F8000H to FBFFFH for user applications.

Keyboard: It has 56 keys which include alphanumeric A-Z and 0-9 special ASCIIsymbols.

Display: An On-board 40x2 LCD module or a *)x24 monochrome monitor can beused. The later requires a Hercules card.

Printer interface: BGC-8088 provides a standard Centronics printer interface. The connection cable is the same as those used in IBM PCs.

RS-232 interface. The 8250 controls the RS-232 interface. It can be programmed forbaud rate, data bit, and stop bit.

I/O expansion slot: The signals are compatible with the IBM PC expansion slot, butno DMA function is provided.

Status port: The status port is used to display keyboard statuses such as Caps Lock,Ins, and Ctrl-P. A correspondent LED is lighted when the function is enabled. Inaddition, it provides the speaker interface to generate sound.

Parallel control interface: Three IC’ s are used to provide parallel controls. They are8255- three 8-bit I/O ports, 8254, - three timers, and 8259A – five interrupt signals.

Power supply: +5V, -5V, +12V, -12V and GND are used in this system.

Page 3: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

3

Software architecture of BGC-8088 Micro-engineer V3.4 Trainer

The BGC-8088 is designed to allow the user to access system programs and apply these programsto user’ s own applications. In addition, an I/O driver routine is available for each I/O device. These routines can be called by issuing an interrupt instructions in the user’ s application programs. The following diagram illustrates the software architecture.

System Program User Program

I/O Drivers

HardwareSystem Commands:

The system commands provide

Memory management

Program control

Numeric operation / conversion

I/O control.

Communication.

I/O Drivers:

The I/O drivers of BGC-8088 provide the software interface between the system and I/O devices.

RS-232 driver.

Keyboard driver

Printer driver

Hercules card driver

LCD display driver

Return to BIOS (system)

Assignment: Note down the IC part numbers used in the BGC-Trainer. Download the datasheets of each IC. Write summary of each IC.

Page 4: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

4

Laboratory Exercise 1 (b)Objective:

Introducing the syntax and use of the system commands of BGC trainer.

Description:

The system commands can be divided into the following groups according to their functions.

Memory Management Commands. Assembler Commands. Numerical Operation Commands. Program Execution Commands.

Each command begins with a command letter followed by 1 to 3 operand parameters. Theparameters of system commands are described below.

<Address> consists of two portions. Segment address: Offset address.Segment registers, CS, DS, ES and SS are often used to hold a segment address. Segment address can be omitted, but the offset value must beindicated.

<Range> indicates an operation section of memory. The syntax for range must be one of th efollowing.

N <Address 1><Address 2> <Address 1> is the starting address, and could contain both segment and

offset addresses. <Address 2> is the ending address and contain only offset address. The addresses in <Range> must be in the same segment. The value of <address 2> must be greater or equal to the offset address

in <address 1>

<Number> a 4 digit hexadecimal number.<Byte> a 2 digit hexadecimal number.<String> a set of characters included in single or double quotation marks.

<Series> a series of <number>s, <byte>s, and /or <string>s, separated by commas.

Note: Hexadecimal numerical system is used throughout the experiments (unless otherwise

specified). The suffix ‘H’ can be omitted.

Page 5: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

5

Memory Management Commands

C Compare the contents of two blocks of memory.D Display the contents of memory. E Edit (Write) data into memory. F Fill the memory with a value.M Move the contents of memory.

Command C: Compare the contents of two blocks of memoryCommand syntax C<Range>,<Address>

<Range> indicates the source area <Address> is the starting address of the target memory block. If any mismatch is found, the system displays both the source and target addressees and

their contents.

Command D: Display the contents of memoryCommand syntax D<Range>

It will display the contents of a specified memory location. The ASCII codes for this value will also displayed. <Range> tells the D command what range of memory to display. If range is not specified, then the default starting address is set to the location following the

last address used by a previous D command. It there is no previous D commands, then the default starting address is 0100:0000. The default length of display is 80H.

Command E: Edit (Write) data into memoryCommand syntax E<Address><Series>

It is used to write data into memory. When E command is used without a <series> parameter; the system displays the <address> and

its contents, a byte of data. The user then types in a new byte of data, (two hexadecimal digits), to replace it. If <CR> is pressed, the next address can be edited. Memory can be edited until <Q> is pressed to exit the E command.

Command F: Fill the memory with a valueCommand syntax F<Range><Series>

It is used to change the contents of a block of memory to a certain sequence of values. The memory locations specified in <Range> are filled with the values specified in <series>.

Page 6: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

6

Command M: Move the contents of memoryCommand syntax M<Range>,<Address>

It move the contents of a block of memory specified in <Range> from one place to another. The starting address of the destination is specified in <Address>. There are two different procedures for moving memory.

1. The first is used when the <Range> block occurs before the destination address.2. The second is used when the destination start address is less than the source start address.

.

The destination occurs before the sourceIf the starting address of <Range> is greater than <Address>, data is moved from the starting address of <Range> to <Address> in ascending order.

The source occurs before the destinationIf the starting address of the <Range> is smaller than <Address>, then the bytes of the <Range> are moved to the destination <Address> in descending order. This means that thelast byte in the <Range> is moved to the last location in the destination first.

Assembler Commands

A Assemble a program.U Disassemble a programI Insert an instruction in a program.

Command A: Assemble a programCommand syntax A [<Address>]

It is used to program with the 8088 assembly language. Since memory space on the BGC-8088 is restricted, the assembler is limited in comparison to a

PC macro assembler, these limitations are listed below. The assembler translate instructions into machine code and stores them in memory

immediately after they are entered. There is no linking function. There is no macro function. Names and labels cannot be used to define the locations of the data segment or the code

segment.

NOTE: <Range> and <Address> may be overlapped.However, overlapping will destroy the original memory contents

Page 7: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

7

Command U: Disassemble a programCommand syntax U [<Range>]

It is used to disassemble assembly language instructions into machine code. <Range> is used to select a block of memory to disassemble. If <Range> is not specified, then the system will start immediately after the final address of the

last U command. If no U command have been executed, the default starting address is CS: IP, which is set to

0100:0000 after power-on. The default length is 20H.

Command I: Insert instruction into a programCommand syntax I [<Address>]

The I and A command can both be used to enter 8088 assembly language instructions. However, these two commands differ in how memory is handled. The A command overwrites the contents (machine codes) of the specified memory, While I command only pushes the contents back one location without erasing them. The INS key is used in toggle mode.i.e by pressing it will insert instructions into memory. As long

as the INS LED is ON, the only way to leave insert mode is to press the INS key once again.

Numerical Operation Commands

B Decimal to binary conversion.H Compute the sum and difference of 2 hexadecimal numbers.J Decimal to hexadecimal conversion. S Hexadecimal to decimal conversion. V Binary to decimal conversion.

Command B: Converting decimal to binaryCommand syntax B<Decimal number>

The range of decimal numbers on the BGC-8088 is 0 to 4294967295 (i.e. 65535 x 65535) Negative numbers are not considered. The binary representation for numbers in this range requires up to 32 bits. When the binary values is displayed, the leading zeroes are omitted, and B is appended to denote

that the number is binary. If the decimal number is greater than 4294967295, it can not be converted into binary.

Command J: Converting decimal to hexadecimalCommand syntax J<Decimal number>

Page 8: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

8

The range of decimal numbers is from 0 to 4294967295 , up to 8 digits are needed in the hexadecimal representation of a decimal number.

As with the B command, the leading zeros or the result are not displayed and an H is suffixed todenote that the number is in hexadecimal.

Command S: Converting hexadecimal to decimalCommand syntax S<Hexadecimal number>

The range of decimal numbers is from 0 to FFFFFFFF, and no negative numbers are considered.

Therefore, the maximum decimal number is 4294967295. In the result, the leading zeros are not displayed and a D appended to denote

decimal representation. If the input value is non-hexadecimal or greater than FFFFFFFF, no conversion is executed and

an error message is issued.

Command V: Converting binary to decimalCommand syntax V<Binary number>

The range of decimal numbers is from 0 to 11111111111111111111111111111111 (32 bits) Negative numbers are not considered. Therefore, the decimal result will not exceed 4294967295. In the result the leading zeros are not displays and a D is used to denote decimal representation.

Command H: Calculate the sum and differenceCommand syntax H<Value 1>,<Value 2>

If the sum is greater than FFFF the carry is discarded. Only 16 bits (4 hexadecimal digits) of the result are displayed. If <Value 1> is smaller than <Value 2>, a borrow is used to execute subtraction.

Program Control Commands

G Execute programR Display or modify the contents of registers.T Trace program execution.

Command G: Execute programCommand syntax G[=<Start address>],[<Break point 1>, <Break point 2>... <Break point n>]

The ‘ =’ sign in the above syntax indicates that a <Start address> parameter will be given. If this symbol is not used , then the system assumes that any parameters are break points. <Start address> specifies the beginning address of the program to be executed. f it is not present, execution will start at the default value, which is the current CS: IP. <Break point> tells the program results to determine whether the program runs as expected.

Page 9: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

9

Up to 10 break points are allowed. Multiple break points make debugging easier when the program contains flow control

instructions, such as JNZ, JC, JNE etc. If no break point is set, control will not return to the user, until the program execution is

completed.

Command R: Check / change the register contentsCommand syntax R[=<Register>]

The R command is used to check or change the contents of the 14 register in the BGC-8088 . It can be used to dump the register contents, or to display and modify the register contents. These functions can be described in the following ways.

R: Display the register contents If there is no <Register> specified, the R command is used to dump all the register contents

to the screen. The registers are displayed in the following order:

AX, CX, DX, BX, SP, BP, SI, DI, ES, CS, SS, DS, IP and FG.

R: <Register>: Display and modify the register contents. After executing this command, the name and contents of the specified register

are displayed. The use can then modify the register contents, or press the <CR> key to display the

next register in the order mentioned above. To exit this command Q or continuous to press <CR> until all the registers have

been displayed.

RF: Display and modify the contents of the FG register The RF command displays the current status of each flag. The definition of the flag register is as follows.

Flag Register:

MSB LSB15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

XX XX XX XX OF DF IF TF SF ZF XX AF XX PF XX CY

Page 10: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

10

Flags Name Bit = 1 Bit = 0OF Overflow OV NVDF Direction DN UPIF Interrupt EI DITF Trap (Single step) SF Sign N G PLZF Zero ZR NZ AF Auxiliary Carry AC NAPF Parity PE POCY Carry CY NC

Values of each flag Bits.

Command T: Trace program executionCommand syntax T[=<Start address>], [<Value>]

The T command provides single step program execution. It executes one instruction at a time, and displays the register contents after each

instruction. <Start address> is the beginning address for program execution. If it is not specified, the program starts at the current address of CS:IP. <Value> defines the number of instructions to be executed. The default value is 1. The P command is used, then Enter, at instruction LOOP to pass through the looping.

Assignment:

Write atleast first 8-bytes of each Memory Management Command.

Assemble the following code and fill the table.Logical Address Opcode Assembly code comments

MOV AX, 0200H ;MOV BX, 0400H ;ADD AX, BX ;

Give answer for the following questions regarding above results:Why the values 0200H and 0400H are written as 0002 and 0004 respectively?Write the number of bytes each instruction taken and also the value of IP register.

Page 11: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

11

Laboratory Exercise 2

Objective:

To understand the basic assembly language instructions and performing basic arithmetic operations.To understand how the Half-Adder, Full Adder, Half-Subtractor, Full Subtractor, Multiplier and Divisor circuits are implemented as assembly instructions.

Theory:

Addition:Half-Adder is implemented using the instruction ADD. No carry-in but carry-out may occur.Full Adder is implemented using the instruction ADC. Both carry-in and carry-out may occur.

(a) Program to add two 32 bit numbers using ADC (add with carry) command.

Assembly Language Program:

Address Data/Code Mnemonics Comments

-------:0100 MOV AX,1111-------: MOV BX,2000-------: MOV CX,3000-------: MOV DX,4000-------: ADD AX,CX-------: ADC BX,DX

Result :____________________________________________________________Also write the flags affected.

Page 12: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

12

Subtraction:Half-Subtractor is implemented using the instruction SUB.

Full Subtractor is implemented using the instruction SBB. Subtraction is implemented using 2’s complement method.

Steps involved in subtraction1. Takes 2’s complement of subtrahend2. Add it to the minuend.3. Invert the carry.

If CY=0 then result is a positive numberElse if CY=1 then result is a negative number and stored in 2’s complement.

(b) Program to subtract two 32 bit numbers using SBB (Subtract With Borrow )command.

Assembly Language Program:

Address Data/Code Mnemonics Comments

-------:0100 MOV AX,3000-------: MOV BX,2000-------: MOV CX,1000-------: MOV DX,4000-------: SUB AX,DX-------: SBB BX,CX

Result :____________________________________________________________Also write the flags affected.

Page 13: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

13

Multiplication:

Multiplication Operand 1 Operand 2 ResultByte x byte AL Register or memory AXWord x word AX Register or memory DX AXWord x byte AL=byte, AH=0 Register or memory DX AX

(c) Program to multiply two numbers store in registers BL and CL, and store theresult in register DX.

Assembly Language Program:

Address Data/Code Mnemonics Comments

-------:0100 MOV BL, 05-------: MOV CL, 10-------: MOV AL, CL-------: MUL BL-------: MOV DX, AX

Result :____________________________________________________________Also write the flags affecred.

Page 14: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

14

Division:

Division Numerator Denominator Quotient RemainderByte / byte AL=byte, AH=0 Register or memory AL AHWord / word AX=word,DX=0 Register or memory AX DXWord / byte AX=word Register or memory AL AHDW / word DXAX=DW Register or memory AX DX

(d) Program to divide two numbers store in registers BL and CL,

Assembly Language Program:

Address Data/Code Mnemonics Comments

-------:0100 MOV BL, 05-------: MOV CL, 10-------: MOV AH, 00-------: MOV AL, CL-------: DIV BL

Result :____________________________________________________________Also write the flags affecred.

Page 15: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

15

Laboratory Exercise 3 (a)

Objective:

Introducing DEBUG programming (at command prompt using PC).

Description:

DEBUG is a program included in the MS-DOS and PC-DOS operating systems that allows the programmer to monitor a program’s execution closely for debugging purposes. Specifically, it can be used to examine and alter the contents of memory, to enter and run programs, and to stop programs at certain points in order to check or even change data. Student will learn

How to enter and exit DEBUG, How to code, run and debug programs How to look at machine code How to examine and alter the contents of registers and memory, How to examine and alter the FLAG register

Entering and Exiting DEBUG:

To enter and exit the DEBUG, simply type its name at the DOS level:C:\> DEBUG <return>

To quit the DEBUG, type Q at the DEBUG prompt and enterQ <return>C:\>

Coding, Running and Debugging the programs:

To assemble a program, write the following at DEBUG promptA <Starting Address>

Example: - A 100 <return>

Address Data/Code Mnemonics Comments

0100:0100 MOV BL, 05 ;Load data 05 in register BL0100: MOV CL, 10 ;Load data 10 in register CL0100: MOV AL, CL ; Position data0100: MUL BL ;Multiplying0100: MOV DX, AX ; Storing product in register DX

NOTE: DEBUG is not case-sensitive. It is assumed in the above instruction that DEBUG program is on the drive C After enter key pressed, the DEBUG prompt “-“ will appear on the following line.

Page 16: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

16

To run or execute the instructions, write the following at DEBUG prompt

G <return>“G stands for GO”

Assemble the above cod to multiply two numbers and run the instructions using G command.

Various forms of the Go Command -G -G = start address -G = start address ending address -G address

To debug a program, T (Trace) command is used which is a powerful debugging tool

T < = starting address > < number of instructions>

Also, Debug will inform any error by indicating “^Error” just under the faulty instruction.

Looking at the machine code , the Unassemble command:

The unassembled command displays the machine code in memory along with their equivalent Assembly language instructions. The command can be given in either format shown below.

U < starting address > < ending address >U < starting address > < L number of bytes >

Get the above cod to multiply two numbers be unassembled using the U command at DEBUG prompt.

Examine and alter the contents of registers, FLAG registers and memory:

Using the following commands at the DEBUG prompt can examine and alter the contents of memory registers and FLAG registers,

F Fills a block of memory with dataF <starting address> <ending address> <data>F <starting address> <L number of bytes> <data>

D Dumps or Displays contents of memory on the screenD<starting address> <ending address> D <starting address> <L number of bytes>

E Enter command, examines/alters the memory contentsE<address> <data list> E <address>

R check the contents of RegistersRRf ( for FLAG registers)

Page 17: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

17

Laboratory Exercise 3 (b)Objective:

To learn how to create and assemble an executable Assembly Language Programming using Assembler and Linker programs.

Description:

The three steps to be followed to create an executable assembly language program are listed as under

Steps Input Program Output1. Edit the program Keyboard Editor myfile.asm2. Assemble the program myfile.asm TASM or MASM myfile.obj3. Link the program myfile.obj TLINK or LINK myfile.exeWhere, .asm, .obj, and .exe are the extension meaning assembler, object and executable file respectively.

Directives:

.model (memory models)

Memory Models Code segment size Data segment size

Small 64kb 64kb

Medium Can exceed 64kb 64kb

Compact 64kb Can exceed 64kb

Large Both can exceed 64kb (single data array can’t exceed 64kb)

Huge Both can exceed 64kb (single data array can exceed 64kb)

.stack 100hStack memory reserved 100 bytes.dataData segment starts.codeCode segment starts

As it is obvious from the above description that a program is to be typed in by using an editor, like Notepad (in windows) or Edit (in DOS) with the extension “.asm”, it is then presented to an assembler program such as TASM (Turbo Assembler) or MASM (Microsoft’s Macro Assembler) in the following manner, (assuming that you are working on the COMMAND PROMPT)

C:\> MASM myfile.asm < return >If no errors found in the program, MASM will generate an object file. This object file is to be presented to the TLINK (Turbo Linker) or LINK as

C:\> LINK myfile.obj < return > If no errors occur, this will generate an executable file ready to be run stand-alone.

Page 18: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

18

The executable file just created can be analyzed or debugged using DEBUG utility, the method will be

C:\> DEBUG myfile.exe < return >The desired DEBUG commands can then be used.

ACTIVITY:

Write, Run and Analyze a program that adds 5 bytes of data and saves the result. The data should be the following numbers:

25, 12, 15, 1F, 2B

Page 19: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

19

Laboratory Exercise 4

Objective:

To learn how to implement loop in assembly language. To learn how a software program affects the hardware signals and their connections.

Theory:

LOOP Command:

The Loop is implemented by using the command “LOOP” followed by the lable of the instruction where to jump to. The maximum number of iterations (repetitions) is defined in the register CX. The LOOP instruction first decrements the value of count defined in register CX and checks the value of CX register. If the CX register contains a non-zero value the loop continues otherwise the loop stops. For example, following code will add 1 in the value contained in register AL for 10 times.

SUM:

MOV CX, 10MOV AL, 0ADD AL, 1LOOP SUM

;CX=max. count value i.e.; 10;Initializing AL with zero;Add 1 to AL;DEC CX and JNZ SUM

The alternate of the LOOP instruction can be a combination of two commands DEC and JNZ. To demonstrate this the above code can be written as:

SUM:

MOV CX, 10MOV AL, 0ADD AL, 1DEC CXJNZ SUM

;CX=max. count value i.e.; 10;Initializing AL with zero;Add 1 to AL;CX=CX-1;If zero flag is not set i.e.; CX != 0 then jump to SUM

It is also to be noted that the count initialization for the CX value is done outside the loop.

Loops can also be used to insert delays in a Program. In this lab exercise we will require to turn on/off sequentially the LEDs interfaced on the BGC-trainer. To make the sequence visible we need to put a delay in between.

Communicating with the hardware through software:

To communicate with the hardware (Input/Output devices), 8088 microprocessor is provided with the IN and OUT commands. Each I/O device while interfacing to the microprocessor is assigned a port address through which it can access the processor and can be accessed by the processor.Requirement for IN command:

DX=Port address, AL=value from the portIN command sequence:

MOV DX, portAddressIN AL, DX

Requirement for OUT command:DX=Port address, AL=value to the port

OUT command sequence:MOV DX, portAddressMOV AL, valueOUT DX, AL

Page 20: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

20

Description: The program controls the input signals SD0, SD1 and SD2. When one of these signals is low (L) or logic “0” the corresponding LED is turn ON. By adjusting the level of the input signals, the program can turn each LED OFF or ON at anytime. In this program, the LEDs are turned ON and OFF in sequence to make them blink. The frequency of blinking cycle is determined by the contents of the CX register. Changing the value in the CX register changes the blinking frequency.

Assembly Language Program:

Address Data/Code Mnemonics Comments

-U0,1b0100:0000 BA70FF MOV DX,FF700100:0003 BOFE MOV AL,FE0100:0005 EE OUT DX,AL0100:0006 B9401F MOV CX,1F400100:0009 E2FE LOOP 00090100:000B B0FD MOV AL,FD0100:000D EE OUT DX,AL0100:000E B9401F MOV CX,1F400100:0011 E2FE LOOP 00110100:0013 B0FB MOV AL,FB01000015 EE OUT DX,AL0100:0016 B9401F MOV CX,1F400100:0019 E2FE LOOP 00190100:001B EBE3 JMP 0000-g

Page 21: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

21

Laboratory Exercise 5 (a)Objective:

Using MASM/TASM learn how to use different BIOS and DOS Interrupt Services.

Description:

There are some extremely useful subroutines within BIOS and DOS that are available to the user through the INT (Interrupt) instructions. The INT instruction is somewhat like a FAR CALL. When it is invoked, it saves the value of CS:IP for the next instruction to be executed and flags on the stack and load the value of the CS:IP of the ISR (Interrupt Service Routine), associated with the interrupt, from the IVT (Interrupt Vector Table). The INT instruction has the following format

INT xx ;the interrupt number xx can be 00 to FFh

This makes 256 interrupts in 80x86 microprocessors. Of these 256 interrupts, two are widely used namely, INT 21H (DOS) and INT 10H (BIOS). Each of them can perform number of functions. Various functions of INT 21H and INT 10H are selected by the value put in the AH register,

To display character → function 2 with int 21h To display string → function 9 with int 21h To clear the screen → function 6 with int 10h To set the cursor → function 2 with int 10h

Download the documents regarding int 10h and int 21h from the course website. http://www.ee322.tk.

Activity 1:

Write and run an Assembly language program to display “Hello World!”

Activity 2:

Write and run an Assembly language program to clear the screen and then set the cursor at desired location on the screen and display “Hello World!”

Activity 3:

Write and run an Assembly language program to clear the screen and then set the cursor at desired location on the screen and display the table of any number from 2 to 10.

Page 22: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

22

Laboratory Exercise 5 (b)Objective:

To demonstrate string handling in assembly language.

Description:

String: A series of data words (or bytes) that reside in consecutive memory locationsExamples: move, scan, compareSome commands use for string handling

Page 23: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

23

Activity 1:

Write and assemble a program in assembly language that scans the name “Mr. Gones” and replaces the “G” with the letter “J”.

Activity 2:

Write and assemble a program in assembly language that scan the input string and determine if it has letter “O” in it.

Activity 3:

Write and assemble a program in assembly language which compare the input string with a pre

defined string (password) and displays “Access Granted” on matching and displays “Access

Denied” if both the strings do not match.

Page 24: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

24

Laboratory Exercise 6(a)Objective:

Introduction of Emulator (Emu8086) and stepper Motor

Materials:

Emulator (EMU8086)

Web Site:www.emu8086.com

Description:

Emulator:Emulator runs programs on a Virtual PC, this completely blocks your program from accessing real hardware, such as hard-drives and memory, since your assembly code runs on a virtual machine, this makes debugging much easier.

Everything for learning assembly language in one pack! Emu8086 combines an advanced source editor, assembler, disassembler, software emulator (Virtual PC) with debugger, and step by step tutorials. This program is extremely helpful for those who just begin to study assembly language. It compiles the source code and executes it on emulator step by step. Visual interface is very easy to work with. You can watch registers, flags and memory while your program executes. Arithmetic & Logical Unit (ALU) shows the internal work of the central processor unit (CPU).

Virtual Devices

Traffic Lights - Port 4 (word)

The traffic lights are controlled by sending data to I/O Port 4.There are 12 lamps: 4 green, 4 yellow, and 4 red.

You can set the state of each lamp by setting its bit:

1 - the lamp is turned on.0 - the lamp is turned off.

Only 12 low bits of a word are used (0 to 11), last bits (12 to 15) are unused.

For example:

MOV AX, 0000001011110100bOUT 4, AX

Page 25: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

25

We use yellow hexadecimal digits in caption (to achieve compact view), here's a conversion:

Hex - Decimal

A - 10 B - 11 C - 12 (unused) D - 13 (unused) E - 14 (unused) F - 15 (unused)

First operand for OUT instruction is a port number (4), second operand is a word (AX) that is written to the port. First operand must be an immediate byte value (0..255) or DXregister. Second operand must be AX or AL only.

If required you can read the data from port using IN instruction, for example:

IN AX, 4

First operand of IN instruction (AX) receives the value from port, second operand (4) is a port number. First operand must be AX or AL only. Second operand must be an immediate byte value (0,255) or DX register.

Page 26: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

26

Stepper Motor - Port 7 (byte)

The Stepper Motor is controlled by sending data to I/O Port 7.

Stepper Motor is electric motor that can be precisely controlled by signals from a computer.

The motor turns through a precise angle each time it receives a signal.

By varying the rate at which signal pulses are produced, the motor can be run at different speeds or turned through an exact angle and then stopped.

This is a basic 3-phase stepper motor, it has 3 magnets controlled by bits 0, 1 and 2. Other bits (3..7) are unused.

When magnet is working it becomes red. The arrow in the left upper corner shows the direction of the last motor move. Green line is here just to see that it is really rotating.

For example, the code below will do three clock-wise half-steps:

MOV AL, 001b ; initialize.OUT 7, AL

MOV AL, 011b ; half step 1.OUT 7, AL

MOV AL, 010b ; half step 2.OUT 7, AL

MOV AL, 110b ; half step 3.OUT 7, AL

If you ever played with magnets you will understand how it works. If required you can read the data from port using IN instruction, for example: IN AL, 7

Page 27: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

27

Activity 1:

Rotate the Stepper Motor one complete revolution clockwise.

Activity 2:

Rotate the stepper motor “N” times clockwise and “M” times counter clockwise, where N & M represents last two digits of your roll number.

Activity 3:

Write and assemble a program to run traffic lights module.

Page 28: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

28

Laboratory Exercise 6(b)Objective:

To perform some computation by using Assembly Language Programming. To generate Fibonacci series To generate BCD count

Description:

The Fibonacci Series is a sequence of numbers first created by Leonardo Fibonacci (fi-bo-na-chee) in 1202. It is a deceptively simple series, but its ramifications and applications are nearly limitless. It has fascinated and perplexed mathematicians for over 700 years, and nearly everyone who has worked with it has added a new piece to the Fibonacci puzzle, a new tidbit of information about the series and how it works. Fibonacci mathematics is a constantly expanding branch ofnumber theory, with more and more people being drawn into the complex subtleties of Fibonacci's legacy. (do visit http://en.wikipedia.org/wiki/Fibonacci_number)The series is like0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393,

In computing and electronic systems, binary-coded decimal (BCD) is an encoding for decimal numbers in which each digit is represented by its own binary sequence. Its main virtue is that it allows easy conversion to decimal digits for printing or display and faster decimal calculations. Its drawbacks are the increased complexity of circuits needed to implement mathematical operations and a relatively inefficient encoding – it occupies more space than a pure binary representation. In BCD, a digit is usually represented by four bits which, in general, represent the values/digits/characters 0-9.

Activity 1:

Write and run an Assembly language program to generate the Fibonacci series upto 233.

Activity 2:

Write and run an Assembly language program to generate two digit BCD up/down counts(00 – 999).

Page 29: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

29

Laboratory Exercise 7(a)Objectives:

To examine and use an 8051 assembler. To examine and use an 8051 simulator. To examine the flag bits of the PSW. To examine the stack.

Reference:

Mazidi and McKinlay, “The 8051 Microcontroller and Embedded Systems,” Chapter 2.

Materials:

8051 assembler and simulator from Franklin Software Inc., Keil Corporation, or the assembler of your choice.

Web Sites:www.keil.com for Keil Corporation

Activity 1

Write and assemble a program to move value 99H to register A. Then from register A move it to all registers R0 - R7. Use the simulator to single-step the program and examine the registers.

Activity 2

Write and assemble a program to add all the single digits of your ID number and save the result in R2. Pick 7 random numbers (all single digit) if you do not want to use your ID number. Then use the simulator to single-step the program and examine the registers.

Activity 3

Write and assemble a program that Sequentially and repeatedly turn on/off the 8 LEDs from the leftmost LED to the rightmost LED.

Activity 4

Write and assemble a program to add the following data and then use the simulator to examine the CY flag. 92H, 23H, 66H, 87H, F5H

Activity 5

Write and assemble a program to load values into each of registers R0 - R4 and then push each of these registers onto the stack. Single-step the program, and examine the stack and the SP register after the execution of each instruction.

Page 30: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

30

Activity 6

Write and assemble a program to:(a) Set SP = 0D, (b) Put a different value in each of RAM locations 0D, 0C, 0B, 0A, 09, and 08,(c) POP each stack location into registers R0 - R4.

Use the simulator to single-step and examine the registers, the stack, and the stack pointer.

Page 31: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

31

Laboratory Exercise 7(a)

Worksheet1. Indicate the size (8- or 16-bit) of each of the following registers.

PC = A= B=

R0= R1= R2= R7=

2. For Question 1, indicate the largest value (in decimal) that each register can contain.

PC = A= B=

R0= R1= R2= R7=

3. For Question 1, indicate the largest value (in hex) that each register can contain.

PC = A= B=

R0= R1= R2= R7=

4. Who generates each of the following files and what is the use of each.

.asm

.lst

.obj

.abs

.hex

Page 32: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

32

5. Find the value of the CY flag after the execution of the following code.

(a) MOV A,#85HADD A,#92H

(b) MOV A,#15HADD A,#72H

(c) MOV A,#0F5HADD A,#52H

(d) MOV A,#0FFINC A

6. Upon reset, what is the value in the SP register?

7. Upon pushing data onto the stack, the SP register is _____________ (decremented, incremented).

8. Upon popping data from the stack, the SP register is ___________ (decremented, incremented).

9. Can you change the value of the SP register? If yes, explain why you would want to do that.

10. The stack uses the same area of RAM as bank ______.

Page 33: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

33

Laboratory Exercise 7 (b)

Objectives:

Introduction to MTS-51 Microcontroller Trainer. This experiment demonstrates that I/O port 2 controls LED pack D5 on the MTS-51 Trainer.

When P2 bit is 1, the corresponding LED is turned ON. When P2 bit is 0, the corresponding LED is turned OFF. Place the SW2-4 in ON position.

Materials:

8051 assembler and simulator. MTS-51 Trainer

Activity 1

Sequentially and repeatedly turn on/off the 8 LEDs from the leftmost LED to the rightmost LED. The on time of each LED is 0.1 seconds.

Activity 2

Sequentially and repeatedly turn on/off the 8 LEDs from the leftmost LED to the rightmost LED. When the rightmost LED is reached, the sequence is inverted. The on time of each LED is 0.1 seconds.

Activity 3

Sequentially turn on/off two LEDs from the two ends towards the middle. When the middle reached, the sequence is inverted. The ON time of each LED is 1 second.

Activity 4

Turn on LEDs according to the following cases and repeat each case 8 times.Case 1: Turn on LEDs from left to right.Case 2: Turn on LEDs from right to left.Case 3: Blink two sets (left and right sides) of LEDs alternately.Case 4: Blink all of 8 LEDs.

Page 34: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

34

Laboratory Exercise 8 (a)

Objectives:

This experiment uses the two-digit 7-segment display (DS3-DS4) of MTS-51 Trainer to show decimal numbers.

Materials:

8051 assembler and simulator. MTS-51 Trainer

Activity 1 (Two-Digit Up Counter)

Sequentially and repeatedly show the numbers 00 through 99 on DS3 and DS4. Each number stays on 0.5 seconds.

Activity 2 (Two-Digit Down Counter)

Sequentially and repeatedly show the numbers 99 through 00 on DS3 and DS4. Each number stays on 0.5 seconds.

Activity 3

Sequentially show the numbers from 00 to 99 and then from 99 to 00 on DS3 and DS4, and repeat the sequence. Each number stays on 0.7 seconds.

Activity 4

Sequentially show the numbers from 00 to 99 on DS3 (ten digit) and DS4 (Units digit) using table look up. Each number stays on 0.3 seconds.

Page 35: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

35

Laboratory Exercise 8 (b)

Objectives:

To demonstrate the on-board Speaker control with the microcontroller on the MTS-51 Trainer.

Materials:

8051 assembler and simulator. MTS-51 Trainer

Hardware Description:

The signal to the speaker driver input comes from P3.7 pin. When a HIGH is fed to it the speaker turns ON. When a LOW is fed the speaker is turned OFF.

Activity 1 (Speaker control)

Generate a 1-KHz tone for the Speaker interface on the MTS-51 trainer.

Activity 2

Speaker sounds a 1 KHz tone for 0.5 seconds and then keeps silence 0.5 seconds.

Page 36: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

36

Laboratory Exercise 9

OBJECTIVES:

This experiment demonstrates the interfacing and control of 8x8 dot matrix LED (D3). And uses it to display static and dynamic alphabets and decimal number.

HARDWARE DESCRIPTION:

The D3 is a common cathode matrix LED. The row scan signal is emitted from P2 and the column scan signal is emitted from P0. Both row and column scan signal are active-high signals, that is, all LEDs are turned on when the row and column signals are all 1s. The 2803 Darlington pairs are used to sink column currents.

MATERIALS:

8051 assembler and simulator. MTS-51 Trainer

ACTIVITY 1 (Basic Matrix LED Control)

Sequentially turn on the column LEDs from column 1 to column 8 eight times, and then turn on the row LEDs from row 1 to row 8 eight times.

ACTIVITY 2 (Static Character Display-1)

Show a 5x7 letter “A” on dot matrix LED.

ACTIVITY 3 (Static Character Display-1)

Sequentially show 5x7-dot characters A through Z and numbers 0 through 9.

ACTIVITY 4 (Dynamic Character Display)

Sequentially show 5x7-dot characters A through Z and numbers 0 through 9, and move it from the left to right.

Page 37: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

37

Laboratory Exercise 10

OBJECTIVES:

To learn Step Motor interfacing and to control the on-board 4-phase step motor M1 on MTS-51 Trainer.

HARDWARE DESCRIPTION:

The motor coils A, B, A’, B’ are energized by the signals on P2.3, P2.2, P2.1, P2.0, respectively. Place switch SW2_8 in ON position. There are three switching schemes: 1-phase-on, 2-phase-on and 1-2-phase-on switching.

MATERIALS:

8051 assembler and simulator. MTS-51 Trainer

ACTIVITY 1 (Direction Control)

Drive the Step-motor to rotate in Clock-Wise (CW) direction using 2-phase-on switching.

ACTIVITY 2 (Revolution Control)

Drive the Step-motor to rotate one revolution CW and then rotate one revolution CCW, continuously.

ACTIVITY 3 (Speed Control)

Drive the Step-motor to rotate one revolution CCW and then rotate two revolutions CW but with double the CW revolution speed, continuously.

Page 38: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

38

Laboratory Exercise 11

OBJECTIVES:

This experiment demonstrates the matrix keyboard control. Using the matrix keyboard control to the 4-phase step motor M1 on MTS-51 Trainer.

Hardware Description:

The matrix keyboard KB1 and ecoder 74C922 builds the keyboard circuit. If a key is pressed , the corresponding binary value will present on the outputs DOD-DOA (P1.3 – P1.0) of the encoder, as well as Data Available (DA) signal on the DA output. The DA signal is inverted by an inverter and then connected to P3.2 (INT0) pin.

MATERIALS:

8051 assembler and simulator. MTS-51 Trainer

ACTIVITY 1 (Keyboard Controls 7-Segment)

1. Show the key number on the 7-segment display DS4 when a key is pressed.2. Place SW2-3 in ON position.

ACTIVITY 2 (Keyboard Controls LED)

Using the following keys on matrix keyboard, control the state of LEDs:a) Key “0” pressed, all the 8 LEDs light up simultaneously.b) Key “1” pressed, all the 8 LEDs blink.c) Key “2” pressed, two sets (left and right sides) of LEDs blink alternately.

ACTIVITY 3 (Step Motor Direction Control)

1. Key “1” pressed, the step motor rotates one step CW.2. Key “2” pressed, the step motor rotates two step CCW.

ACTIVITY 4 (Step Motor Revolution Control)The step motor rotates CW the same number of revolutions as the key pressed (0-9)

Page 39: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

39

Laboratory Exercise 12

OBJECTIVES:

This experiment demonstrates the application of LCD module (LCM). LCMs are widely used to display alphanumeric characters. The LCM on MTS-51 Trainer is a 20 characters x 2 lines back-light LCM.

Hardware Description:

SW2-5 should be placed in ON position. P0 lines are connected to the data bus DB0-DB7 of LCM. P1.5, P1.6, and P1.7 are connected to RS, R/W, and E pins, respectively.

MATERIALS:

8051 assembler and simulator. MTS-51 Trainer

ACTIVITY 1 (LCM Character Display-1)

Show the character string “Hello ! Welcome” in the middle of the first line of LCM.

ACTIVITY 2 (LCM Character Display-2)

Show the character string “Sir Syed University” in the middle of the first line of LCM and blink it every 0.5 second interval.

ACTIVITY 3 (LCM Character Display-3)

Show the character string “Hello ! Welcome” on the right side of the first line of LCM and slowly move to the middle position, and blink it.

ACTIVITY 4 (LCM Character Display-4)

Show the key value on the LCM screen and blink the cursor.

ACTIVITY 5 (LCM Character Display-5)

Design a 4-digit counter which automatically increments its value every second, and shows the result in the middle of the first line of LCM screen.

ACTIVITY 6 (6-Digit Electronic Stopwatch)

Design a stopwatch in the middle of LCM screen in 00:00:00 (minutes:seconds:1/60 seconds) format. The stopwatch has a resolution of 0.01 seconds. When the key “1” is pressed, the watch starts or resumes counting. When the key “2” is pressed, pause counting. When the key “2” is pressed, the watch is reset.

Page 40: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

40

Laboratory Exercise 13

OBJECTIVES:

To learn on-chip Timer/ counter control and their operation in Modes 0 and 1. Demonstrate the operation of basic pulse counter

Hardware Description:

Mode 0: 13-bit timer Mode 1: 16-bit timer/ counter SW2-4 should be placed in ON position.

MATERIALS:

8051 assembler and simulator. MTS-51 Trainer

ACTIVITY 1 (Timer/counter Mode-0)

Program timer/counter 0 operating in mode 0 and blink LEDs (D5) alternately. The ON/OFF time is 1 second.

ACTIVITY 2 (Timer/counter Mode-1)

Program timer/counter 0 operating in mode 1 and sequentially turn on/off LEDs from leftmost to the rightmost. The ON/OFF time is 0.5 seconds each.

ACTIVITY 3

Count the number of pulses from the 555 oscillator output and show the result on 7-segment displays.

Page 41: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

41

Laboratory Exercise 14

OBJECTIVES: This experiment demonstrates the control application of photo interrupter.

Hardware Description:

The MTS-51 has two photo-interrupts PH1 and PH2. When light is blocked, the phototransistor is cut off and low presents on the inverter output terminal. When light is not blocked the phototransistor conducts in saturation and a high presents on the inverter output terminal

MATERIALS:

8051 assembler and simulator. MTS-51 Trainer

ACTIVITY

Use PH2 output to control the direction of rotation of the step motor. When PH2 is not blocked by an object (for example, a piece of paper), the step motor rotates CW. If PH2 is blocked by an object, the step motor rotated CCW.

Page 42: Microprocessor and Interfacing Techniques (TE-380 ...umartalha.weebly.com/uploads/8/3/8/2/8382263/lab_manual_micro2013… · Microprocessor and Interfacing Techniques (TE-380) Telecommunication

Microprocessor and Interfacing Techniques (TE-380)

Telecommunication Engineering DepartmentSir Syed University of Engineering & Technology

42

Laboratory Exercise 15

OBJECTIVES:

This experiment demonstrates the Serial Communication using on-chip serial port Mode 1. This experiment demonstrates the Output port expansion using serial port Mode 0.

Hardware Description:

The serial port in mode 0 acts a shift register which sends 8 data bits through RXD and the TXD on transmit. SIPO is followed.

If two MTS-51 trainers are used, the JP2s on MTS-trainers should be interconnected such that TXD of one is connected to the RXD of other, with a common Ground for both.

MATERIALS:

8051 assembler and simulator. MTS-51 Trainer

ACTIVITY 1 (UART in Mode-1)

When a key is pressed on one MTS-51 trainer, the key is displayed on the 7-segment of the other MTS-51 trainer

ACTIVITY 2

Program for the following sequence:1. Sequentially turn on/off LEDs from left to right, 4 times2. Sequentially turn on/off LEDs from right to left, 4 times3. Sequentially turn on/off LEDs from left to right, and then invert the sequence 2 times.4. Blink two sets of LEDs (right and left sides) alternately, 4 times5. Turn on/off two LEDs ends to the middle and then from middle to ends, 4 times

[Place SW2_2 in ON position to enable LED pack 04]