15EI302L-MICROCONTROLLER BASED SYSTEM DESIGN …

IOs Reference 7 Stepper motor control using 8051 controller 3 C,D,I 1,3 1,3 8 Temperature control system using 8051 3 C,D,I 1,3 1,3 9 LCD Display usin...

0 downloads 46 Views 2MB Size
15EI302L-MICROCONTROLLER BASED SYSTEM DESIGN LABORATORY MANUAL

Department of Electronics and Instrumentation Engineering

Faculty of Engineering and Technology Department of Electronics and Instrumentation engineering SRM Institute of Science & Technology SRM Nagar , Kattankulathur – 603203, Kancheepuram District Tamil Nadu

1

CONTENTS

S.No. 1 2 3 4 5

CONTENTS Mark Assessment details General Instructions for Laboratory classes Syllabus Introduction to the laboratory List of Experiments 5.1 Addition, Subtraction, Multiplication and Division 5.2 Finding the maximum value in an array. 5.3 Sorting of data. 5.4 BCD-to-Hex conversion and Hex-to-BCD conversion. 5.5 Block data transfer (forward and reverse) Interfacing with Application Boards 5.6 Traffic light control using 8051 5.7 Stepper motor control using 8051 controller 5.8 Temperature control system using 8051 5.9 LCD Display using 8051 5.10 Seven segment display using nuvoTon (NUC140) board

2

Page No. 3 4 5 7 8 28 36 44 52 56 64 68 70 71 74

1. MARK ASSESSMENT DETAILS ALLOTMENT OF MARKS:

Internal assessment

=

Practical examination =

60 marks 40 marks

---------------------Total

=

100 marks

----------------------

INTERNAL ASSESSMENT (60 MARKS) Split up of internal marks

Record Model exam Quiz/Viva Experiments Total

5 marks 10 marks 5 marks 40 marks 60 marks

PRACTICAL EXAMINATION (40 MARKS)

Split up of practical examination marks

Aim and Procedure Circuit Diagram Tabulation Result Viva voce Total

3

25 marks 30 marks 30 marks 05 marks 10 marks 100 marks

2. GENERAL INSTRUCTIONS FOR LABORATORY CLASSES 1. . Enter the Lab with CLOSED TOE SHOES. 2. Students should wear lab coat. 3. The HAIR should be protected, let it not be loose. 4. Students should come with observation and record note book to the laboratory. 5.

Students should maintain silence inside the laboratory.

6. TOOLS, APPARATUS and COMPONENT sets are to be returned before leaving the lab.

7. HEADINGS and DETAILS should be neatly written i.

Aim of the experiment

ii.

Apparatus / Tools / Instruments required

iii.

Theory

iv.

Procedure / Algorithm / Program

v.

Model Calculations/ Design calculations

vi.

Block Diagram / Flow charts/ Circuit diagram

vii.

Tabulations/ Waveforms/ Graph

viii.

Result / discussions

8. Experiment number and date should be written in the appropriate place.

9. After completing the experiment, the answer to pre lab viva-voce questions should be neatly written in the workbook.

10. Be REGULAR, SYSTEMATIC, PATIENT, AND STEADY

4

L

T

P

C

0

0

2

1

Microcontroller based System Design Laboratory

15EI302L

Co-requisite:

15EI302

Prerequisite:

NIL

Data Book / Codes/Standards

NIL

Course Category

P

Course designed by

Department of Electronics and Instrumentation Engineering

Approval

32nd Academic Council Meeting held on 23rd July, 2016

PROFESSIONAL CORE

ELECTRONICS ENGINEERING

PURPOSE

To develop skills in programming and interfacing applications of microprocessors and microcontrollers. INSTRUCTIONAL OBJECTIVES STUDENT OUTCOMES At the end of the course, student will be able to 1.

Improve their ability in their programming skills

b

2.

Equip themselves familiar with interfacing concepts of microprocessors

b

c

d

3.

Equip themselves familiar with interfacing concepts of microcontrollers

b

c

d

Session

Description of Topic

Conduct hours

C-DI-O

IOs

Reference

General Purpose Programming Exercises Using 8086 1

Addition, Subtraction, Multiplication and Division

3

C,I

1,2

1,2

2

Finding the maximum value in an array.

2

C,I

1,2

1,2

3

Sorting of data.

1

C,I

1,2

1,2

4

BCD-to-Hex conversion and Hex-to-BCD conversion.

3

C,I

1,2

1,2

5

Block data transfer (forward and reverse)

3

C,I

1,2

1,2

3

C,D,I

1,3

1,3

Interfacing with Application Boards 6

Traffic light control using 8051

5

Session

Description of Topic

Conduct hours

C-DI-O

IOs

Reference

7

Stepper motor control using 8051 controller

3

C,D,I

1,3

1,3

8

Temperature control system using 8051

3

C,D,I

1,3

1,3

9

LCD Display using 8051/ Nu-LB-NUC140 controller

3

10

8 bit ADC and 8 bit DAC. using nuvoTon (NUC140) board

3

11

Seven segment display using nuvoTon (NUC140) board 30

LEARNING RESOURCES Sl. No.

REFERENCES

1.

Laboratory Manual

2.

N. Senthil Kumar, M. Saravanan and S. Jeevananthan, “Microprocessors and Microcontrollers”, Oxford Publishers,2010..

3.

nuvoTon Cortex M0 (Nu-LB-NUC100/140) Driver and Processor Reference Manual; www.nuvoton.com

Course nature

Practical

Assessment Method (Weightage 100%)

Insemester

Assessment tool

Experiments

Record

MCQ/Quiz/Viva Voce

Model examination

Total

Experiments

Weightage

40%

5%

5%

10%

60%

40%

End semester examination Weightage :

6

40%

4. Introduvction to the laboratory AIM: To study about the basic architecture of 8086 microprocessor. APPARATUS: 8086 micro processor kit Keyboard THEORY: A microprocessor is a multipurpose, programmed clock driven register based system which takes the input in binary process (arithmetic, logical) and gives the output. The 8086 is the first 16-bit microprocessor released by Intel which can execute 2.5 million instructions per second. It has a 20-bit address bus. The main feature of 8086 which makes it better than 8085 is the presence of a six-byte instruction queue in which the instructions fetched from the memory are placed before they are executed. Architecture of 8086

Image - From Microprocessors and Microcontrollers by N.Senthil Kumar

1. Execution Unit – It includes the ALU (Arithmetic Logical Unit), eight 16-bit general7

purpose registers, 16-bit flag register and a control unit. Register Organisation -> 8086 consists of 2 types of register: general purpose and special purpose registers. General purpose register is used for holding data, variables and intermediate results temporarily and can also be used as counters. The Execution Unit consists of eight 16-bit general purpose registers – AX, BX, CX, DX, SP, BP, SI and DI. Among these registers, AX, BX, CX, DX can be divided into two 8-bit registers – AH and AL, BH and BL, CH and CL and DH and DL. The general purpose registers can be used to store 8-bit or 16-bit data during program execution. General Purpose Registers -(i) AX/AL: It is used as the accumulator with the lower 8-bit stored in AL and the higher 8-bits stored in AH. It is used in the multiply, divide and input/output operations. (ii) BX: The BX register holds the offset address of a location in the memory. It is also used to refer to the data in the memory using look-up table technique using XLAT instruction. (iii) CX/CL: It is used as default counter in string and loop instructions (iv) DX: It is used to hold a part of the result during a multiplication operation and a part of the dividend before a division operation. Pointers and Index Registers – The index registers are used as general purpose registers as well as for offset storage. (i) SP: The stack pointer is used to hold the offset address of the data stored at the top of the stack segment. It is used with the SS to decide the address at which the data is to be pushed or popped. (ii) BP: It is also called base pointer. It is also used to hold the offset address of the data to be read from or written into stack segment. (iii) SI: It is also called as source index register. It is used to hold the offset address of the source data in the data segment, while executing string instructions. (iv) DI: It is also called as destination index. It is used to hold the offset address of the destination data in the extra segment, while executing string instructions. Flag Registers – The flags in the flag register can be classified into status flags and control flags. The flags CF, PF, AF, ZF, SF and OF are called status flags, as they indicate the status of the result that is obtained after the execution of an arithmetic or logic instruction. The flags DF, IF, and TF are called control flags, as they control the operation of the CPU. (i) CF: The carry flag holds the carry after an 8-bit or 16-bit addition or the borrow after an 8-bit or 16-but subtraction operation. (ii) PF: If the lower eight bits of the result have an odd parity (i.e., odd number of 1s), parity flag is set is to 0. Otherwise, it is set to 1. (iii) AF: The auxiliary flag holds the carry after addition or the borrow after subtraction of the bits in the bit position 3. (iv) ZF: The zero flag indicates that the result of an arithmetic or logic operation is 8

zero. If z=1, the result is zero and if z=0, the result is not zero. (v) SF: Sign flag holds the arithmetic sign of the result after an arithmetic or logical instruction is executed. (vi) TF: Trap flag is used to debug a program using the single-step technique. If TF=1, the 8086 gets interrupted after the execution of each instruction in the program. (vii) DF: Direction flag selects either the increment or decrement mode for the DI and/or SI, during the execution of string instructions. (viii) IF: Interrupt flag controls the operation of the INTR interrupt pin of the 8086. (ix) OF: An overflow flag indicates that the result has exceeded the capacity of the machine.

Image – Flag register in a 8086 microprocessor 2. Bus Interface Unit – It includes the adder for address calculations, four 16-bit registers (CS, DS, SS, ES) and a 16-bit instruction pointer, a six-byte instruction queue and bus control logic. Special purpose registers are used as segment registers, pointers, index registers or as offset storage registers for particular address modes. The memory consists of 4 types of registers, Code segment registers (CS), data segment register (DS), stack segment registers (SS) and extra segment registers (ES). CS stores the executable program, DS stores the data. The SS holds the stack of the program, which is needed while executing the CALL and RET instructions and also to handle interrupts. The CPU uses the stack for temporarily storing the important data. While addressing any memory location, the physical address is detected from 2 parts, the first is segment address and the second is offset address. Pin Diagram and Explanation of 8086 (i) AD15-AD0: These pins act as the multiplexed address and data bus of the microprocessor. Whenever the ALE (address latch enable) pin is HIGH, these pins 9

carry the address, and whenever it is LOW, these pins carry data. (ii) A19/S6-A16/S3: These pins are multiplexed to provide the address signals A19-A16 and the status bits S6-S3. When ALE =1, these pins carry the address and ALE=0, they carry the status lines. (iii) NMI: The non-maskable interrupt input is a hardware interrupt. It cannot be disabled by software. It is a positive edge-triggered interrupt and when it occurs, the type 2 interrupt occurs in the 8086. (iv) INTR: The interrupt request is a level triggered hardware interrupt, which depends on the status of IF. When IF=1, INTR is held HIGH, the 8086 gets interrupted. (v) CLK: The clock signal must have a duty cycle of 33% to provide a proper internal timing for the 8086. (vi) ̅̅̅̅̅̅̅ 𝑩𝑯𝑬/S7: The Bus High Enable pin is used in the 8086 to enable the most significant data bus during a read/write operation. The state of the status line S7 is always logic 1. ̅̅̅̅̅: This pin is used to select either the minimum mode or the maximum mode (vii) MN/𝑴𝑿 operation in the 8086. ̅̅̅̅̅: Whenever the read signal is at logic 0, the 8086 reads the data from the memory (viii) 𝑹𝑫 or I/O device through the data bus. (ix) READY: This input is used to insert waits states into the timing cycle of the 8086. If the READY pin is at logic 1, it has no effect on the operation of the microprocessor. If it is at logic 0, the 8086 enters the wait state and remains idle. ̅̅̅̅: This pin indicates whether the 8086 is performing memory read/write (x) M/𝑰𝑶 ̅̅̅̅ = 𝟏) or I/O read/write operation (M/𝑰𝑶 ̅̅̅̅ = 𝟎). operation (M/𝑰𝑶 (xi) HOLD: The Hold input requests a direct memory access and is generated by the DMA controller. If the Hold signal is at logic 1, the 8086 completes the execution of the current execution and places its address, data and control buses in the high impedance state. If the Hold signal is at logic 0, the 8086 executes instructions normally. Image – Pin diagram of 8086 microprocessor

10

RESULT: The assembly language program for 8 bit addition of two numbers was executed successfully by using 8085 micro processing kit. Prepared by Dr. K. A. Sunitha 11

Exercise Number 1a Title of the Experiment: ADDITION OF TWO 8-BIT NUMBERS Date of the Exercise:

AIM: (a) To write and execute an assemble language program to add two 8-bit data. (b) To write and execute an assemble language program to subtract two 8-bit data.

APPARATUS REQUIRED: 1. Microprocessor 8086 kit. 2. Keyboard ALGORITHM: Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Step 7 Step 8 Step 9 Step 10 Step 11 Step 12

: : : : : : : : : : : :

Start the microprocessor Initialize the carry as‘Zero’ Load the first 8 bit data into the accumulator Copy the contents of accumulator into the register ‘B’ Load the second 8 bit data into the accumulator. Add the 2 - 8 bit data and check for carry. Jump on if no carry Increment carry if there is Store the added requesting accumulator More the carry value to accumulator Store the carry value in accumulator Stop the program execution.

12

FLOW CHART START

Intialise the carry as zero

Load the 1st 8 bit number Transfer the 1st number to register ‘B’ Load the 2nd 8 bit number Transfer and Add the contents of A and B

No Checkfor carry?

Yes

Increment carry by one Store the added value in accumulator Move the contents of carry into accumulator

Store the value of carry in accumulator

END END

13

PROGRAM: Address 4100 4102 4105

Mnemonics MOV AL,01 MOV BL, 02 MOV CL, 00

Comments Initialize AL Initialise BL Initialise CL for carry

4106

ADD AL,BL

Add AX and BX

4109 410A 410D

JNC100C INC CL MOV[1300],A L MOV AL,CL

Checks for Carry at 100C Increment CL Move AL to address

410E 4111

4112

Move CL to AL

MOV[1301],A Move Al to 1301 location L INT3

End program.

14

Input Without carry Input Address 4300 4301

Value 04 02

Output Address 4302 4303

Value 06 00 (carry)

Input Address 4300 4301

Value FF FF

Output Address 4302 4303

Value FE 01 (carry)

Output

With carry

Calculation

(1)

1111 1111 1111 1111 --------------1111 1110 ======== =F E

RESULT: The assembly language program for 8 bit addition of two numbers was executed successfully by using 8085 micro processing kit.

Prepared by Dr. K. A. Sunitha 15

Exercise Number 1b Title of the Experiment: SUBTRACTION OF TWO 8-BIT NUMBERS Date of the Exercise: AIM: To write an assembly language for Subtracting two 8 bit numbers by using microprocessor kit. APPARATUS: 8086 microprocessor (05V) DC battery ALGORITHM: 1. Load the first data from memory to accumulator. 2. Move the accumulator content to B register. 3. Load the second data from memory to accumulator. 4. Clear C register. 5. Subtract the content of B register to accumulator. 6. Check carry flag if carry is set go to step7 else to step8. 7. Increment C register. 8. Store the answer in memory. 9. Move the C register content to accumulator and store it in memory. 10. Stop.

16

FLOW CHART

START

MOVE TWO INPUTS INTO TWO REGISTERS

INITIALIZE A COUNTER (REGISTER C) AS 00

SUBTRACT THE TWO INPUTS

JUMP NO CARRY

YES

NO

INCREMENT COUNTER

STORE ACCUMULATOR CONTENT (i.e. RESULT) IN MEMORY LOCATION

STORE COUNTER CONTENT IN ANOTHER MEMORY LOCATION

END

17

TABULATION: ADDRESS MNEMONICS COMMENT 8000 MOV AX, 0080 ;MOVE 80 TO REGISTER AX 8001 8002 MOV BX, 0080 ;MOVE 80 TO REGISTER BX 8003 8004 MOV CL,00 ;MOVE 00 TO REGISTER CX 8005 8006 SUB AX,BX SUBTRACT BX FROM AX 8007 JNC100C ;JUMP NO CARRY TO 100C 8008 8009 800A INR CL ;INCREMENT REGISTER CL 800B MOV[1500],AL MOVE AX TO [1500] 800C 800D 800E MOVAX,CX ;MOVE CONTENTS OF CX TO AX 800F MOV[1501],AL MOVE AX VALUE TO 1501 8010 8011 8012 INT3 TERMINATE

18

RESULT: SUBTRACTION OF TWO 8-BIT DATA INPUT

OUTPUT

MEMORY LOCATION

CONTENT

MEMORY LOCATION

CONTENT

8001

08

1500

00

8003

09

1501

01

Thus subtraction of two 8-bit numbers was done and results were verified.

Prepared by Dr. K. A. Sunitha 19

Exercise Number: 1c

Title of the Experiment: MULTIPLICATION OF TWO 8-BIT NUMBERS Date of the Exercise: AIM: To write and execute an assemble language program to multiply two 8-bit data. APPARATUS REQUIRED: 1. Microprocessor 8085 kit. 2. Manual. ALGORITHM: 1. Load the first data from memory to B register. 2. Load the second data from memory to C register. 3. Initialize A register with zero. 4. Add the content of B register to accumulator. 6. Decrement C register. 7. Check zero flag if zero is set go to step8 else to step5. 8. Store the sum in memory. 9. End the program and execute it to display the result.

20

FLOW CHART

START

MOVE TWO INPUTS INTO TWO REGISTERS (B&C)

INITIALIZE THE REGISTER A AS 0

ADD B CONTENT WITH A CONTENT

DECREMENT C REGISTER

NO

CHECK FOR ZERO

STORE THE RESULT IN AN ADDRESS

END

21

TABULATION: ADDRESS 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 800A 800B 800C 800D 800E

MNEMONICS MOV CL,00

COMMENT CLEAR CL REGISTER FOR CARRY

MOV AL,01

MOV

MVI A,00

;MOVE 00 TO REGISTER C

ADD B

;ADD (A)+(B) AND STORE IN A ;DECREMENT REGITER C ;JUMP NO ZERO TO 8006

DCR C JNZ 06 80 STA 8200 00 82 HLT

;INCREMENT REGISTER C ;STORE (A) IN 8200

;HALT

22

RESULT: ADDITION OF TWO 8-BIT DATA INPUT

OUTPUT

MEMORY LOCATION

CONTENT

8001

03

8003

02

MEMORY LOCATION 8200

CONTENT 06

Thus multiplication of two 8-bit numbers was done and result was verified. Prepared by Dr. K. A. Sunitha

23

Exercise Number: 1d

Title of the Experiment:DIVISION OF TWO 8-BIT NUMBERS Date of the Exercise: AIM: To write and execute an assemble language program to divide two 8-bit data.

APPARATUS REQUIRED: 1. Microprocessor 8085 kit. 2. Manual. 3. Op code sheet.

ALGORITHM: 1. Load the first data from memory to accumulator. 2. Move the accumulator content to B register. 3. Load the second data from memory to accumulator. 4. Initialize C register with zero. 5. Compare the numbers to check for carry. 6. Subtract the two numbers 7. Increment C register if there is a carry. 8. Check whether repeated subtraction is over. 9. Store the difference in memory. 10. Move the C register content to accumulator and store it in memory. 11. Stop.

24

FLOW CHART

START

MOVE TWO INPUTS INTO TWO REGISTERS

INITIALIZE A COUNTER (REGISTER C) AS 00

COMPARE THE NUMBERS IN B WITH A

CHECK FOR CARRY

SUBTRACT A-B AND STORE IN A

INCREMENT C

INCREMENT C REGISTERAND JUMP TO 4006

STORE THE ACCUMULATOR VALUE IN AN ADDRESS LOCATION AND COUNTER VALUE IN NEXT ADDRESS LOCATION

END 25

TABULATION: ADDRESS 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 400A 400B 400C 400D 400E 400F 4010 4011 4012 4013 4014 4015 4016

LABEL

MNEMONICS MVI A,04

OP-CODE 3E

CMP B

04 06 02 0E 00 B8

JC 400F

DA

MVI B,02 MVI C,00

STA 4100

0F 40 90 0C C3 06 40 32

MOV A,C STA 4101

00 41 79 32

HLT

01 41 76

SUB B INR C JMP4006

26

COMMENT MOVE 04 TO ACCUMULATOR MOVE 02 TO B REGISTER MOVE 00 TO REGISTER C COMPARE THE DATA IN B WITH A JUMP TO 400F IF CARRY IS PRESENT

SUBTRACT A-B INCREMENT C REGISTER JMP TO 4006

STORE THE DIFFERENCE IN 4100

MOVE DATA IN C TOA STORE DATA IN A TO 4101

STOP

RESULT:

DIVISION OF TWO 8-BIT DATA INPUT

OUTPUT

MEMORY LOCATION

CONTENT

MEMORY LOCATION

CONTENT

4001

04

4100

00

4003

02

4101

02

Thus division of two 8-bit numbers was done and results were verified.

Prepared by Dr. K. A. Sunitha 27

Exercise Number 2 Title of the Experiment: FINDING THE MAXIMUM VALUE OF AN ARRAY Date of the Exercise:

AIM: To sort the numbers in 8086 and obtain a) smallest number b) largest number APPARATUS REQUIRED: 1. 8086 Trainer Kit 2. Keyboard A) Smallest Number:ALGORITHM: 1. Set the SI and DI values. 2. Set CL as counter. 3. Increment SI. 4. Move content to AL. 5. Decrement CL. 6. Increment SI. 7. Compare the content with that of AL. 8. If no borrow, JUMP. 9. If content present, move content to AL. 10. Decrement CL. 11. Jump if no zero. 12. On obtaining largest number, move to DI. 13. Stop the program.

28

FLOW CHART Start

LOAD 1500 IN SI

LOAD 1600 IN DI

MOVE SI CONTENT IN CL INCREMENT SI

MOVE SI CONTENT TO AL DECREMENT CL INCREMENT SI COMPARE SI CONTENT WITH AL CHECK FOR BORROW

MOVE SI CONTENT TO AL

DECREMENT CL CHECK FOR ZERO

MOVE AL TO DI

STOP

29

;

PROGRAM: Address

Mnemonics

Comments

1200

MOV SI, 1580

SI becomes 1508

1204

MOV DI, 1680

DI becomes 1608

1207

MOV CL, [SI]

Move [1508] to CL

1209

INC SI

Increment SI

120A

MOV AL, [SI]

Move [1509] to AL

120C

DEC CL

Decrement CL

INC SI

Increment SI

120E

CMP AL, [SI]

Compare

1210

JNB

Jump if no borrows

1213

MOV AL, [SI]

Move [150A] to AL

DEC CL

Decrement CL

1216

JNZ

Jump if no zero

1219

MOV[DI], AL

Move AL to [DI]

121B

INT 3

Stop

120D

1215

Label

Loop 2

Loop 1

30

RESULT: Input

Output

Address

Input

Address

Output

1580

05

1600

09

1581

01

1583

03

1584

08

1585

09

Thus a set of numbers were sorted and the largest number was obtained. Prepared by Vibha.k

31

B) Largest Number:ALGORITHM: 1. Load SI with 1500 and DI with 1600. 2. Move SI content to CL and increment it. 3. Move SI content to AL. 4. Decrement CL. 5. Increment SI. 6. Compare the content of SI with that in AL. 7. Jump if borrow, to 1016. 8. Move the SI content in AL. 9. Decrement CL. 10. Jump if no zero. 11. Move the AL content in the address of DI. 12. Stop the program.

32

FLOW CHART Start Move 1580 to SI Move 1680 to DI Move [SI] to CL

INCREMENT SI MOVE [SI] TO AL DECREMENT CL INCREMENT SI COMPARE SI CONTENT WITH AL

CHECK FOR BORROW

MOVE SI CONTENT TO AL

DECREMENT CL CHECK FOR

ZERO MOVE AL TO DI STOP

33

PROGRAM: Address

Mnemonics

Comments

1000

MOV SI, 1500

Load SI with 1500

1003

MOV DI,1600

Load DI with 1600

1006

MOV CL, [SI]

Move SI content in CL.

1008

INC SI

Increment SI

100A

MOV AL, [SI]

Move SI content in AL

100C

DEC CL

Decrement CL

INC SI

Increment SI

100F

CMP AL, [SI]

Compare SI content with AL

1011

JB 1016 (loop 1)

Jump if no borrows

1014

MOV AL, [SI]

Move SI content in AL

DEC CL

Decrement CL

1017

JNZ 100D(loop 2)

Jump if no zero

101A

MOV[DI], AL

Move AL in DI

101C

INT 3

Stop

100D

1016

Label

Loop 2

Loop 1

34

RESULT: Input

Output

Address

Input

Address

Output

1500

05

1600

01

1501

01

1502

02

1503

03

1504

04

1505

08

Thus a set of numbers were sorted and the smallest number was obtained. Prepared by Vibha.k 35

Exercise Number: 3

Title of the Experiment: SORTING OF DATA Date of the Exercise:

AIM: To arrange the given set of numbers in ascending and descending order. APPARATUS REQUIRED: 8086 kit Keyboard ASCENDING ORDER :ALGORITHM: Step 1 : Step 2 : Step 3 : Step 4 : Step 5 : Step 6 : Step 7 : Step 8 : Step 9 : Step 10 : Step 11 : Step 12 : Step 13 : Step 14 : Step 15 : Step 16 : Step 17 : Step 18 : Step 19 :

Set 1580 as SI Move SI content to CH counter Decrement CH Move SI content to CL Move 1500 to SI Increment SI Move SI content to AL Increment SI Compare the SI content with AL If borrow jump Move SI content to BL Decrement SI Move BL content to SI Increment SI Decrement CL Jump if no zero Decrement CH Jump if no zero Stop the program

36

FLOW CHART

37

TABULATION : ADDRESS 1001 1004 1006 1007 1009 100C 100D 100F 1012 1014 1017 1018 1019 101A 101B 101C 101D 1020 1021 1024

LABEL MNEMONICS MOV SI, 1580 MOV CH, [SI] DEC CH MOV CL, [SI] Loop 3 MOV SI,1500 INC SI Loop 2 MOV AL, [SI] INC SI CMP AL, [SI] JB 101C MOV BL, [SI] MOV [SI], AL DEC SI MOV [SI], BL INC SI Loop1 DEC CL JNZ 100D DEC CH JNZ INT 3

COMMENTS Move 1580 to SI Move [SI] in CH Decrement CH Move [SI] in CL Move 1500 in SI Increment SI Move [SI] in AL Increment SI Compare [SI] with AL Jump if borrow Move [SI] to BL Move AL in [SI] Decrement SI Move BL in [SI] Increment SI Decrement CL Jump if no zero Decrement CH Jump if no zero Stop the program

38

RESULT: INPUT ADDRESS

OUTPUT INPUT

ADDRESS

OUTPUT

Thus sorting of numbers was done in ascending order successfully.

Prepared by Vibha.k

39

DESCENDING ORDER :ALGORITHM:                  

Move 1580 to SI Move the content of SI to CH Decrement CH Move SI content to CL Move 1500 to SI Increment SI Move SI content to AL Increment SI Compare the SI content with that in AL Jump if no borrow Move AL content to SI Decrement SI Increment SI Decrement CL Jump if no zero Decrement CH Jump if no zero Stop the program

40

FLOW CHART

41

TABULATION: Address

Label

Mnemonics

Comments

1001

MOV SI,1580 Move 1580 to SI

1004

MOV CH,[SI] Move [SI] to CH

1006

DEC CH

Decrement CH

1007

MOV CL,[SI]

Move [SI] to CL

1009

Loop3

100C 100D

MOV SI,1500 Move 1500 to SI INC SI

Loop2

Increment SI

MOV AL,[SI] Move [SI] to AL

100F

INC SI

Increment SI

1012

CMP AL,[SI]

Compare AL with [SI]

1014

JB 101C

Jump if borrow

1017

MOV BL,[SI]

Move [SI] to BL

1018

MOV [SI],AL Move AL to [SI]

1019

DEC SI

Decrement SI

101A

MOV [SI],BL

Move BL to [SI]

101B

INC SI

Increment SI

DEC CL

Decrement CL

101D

JNZ 100D

Jump if no zero

1020

DEC CH

Decrement CH

1021

JNZ 1009

Jump if no zero

1024

INT3

Terminate

101C

Loop1

42

RESULT: INPUT ADDRESS

OUTPUT INPUT

ADDRESS

OUTPUT

Thus sorting of numbers in descending order was done successfully. Prepared by Vibha.k 43

Exercise Number: 4 Title of the Experiment: CODE CONVERSIONS USING 8086 Date of the Exercise:

AIM: (a)To write and execute an assemble language program to perform code conversion for BCD to BINARY (b)To write and execute an assemble language program to perform code conversion for BINARY TO BCD APPARATUS REQUIRED: 4. Microprocessor 8086 kit. 5. Manual.

(a) CODE CONVERSION FOR BCD TO BINARY:ALGORITHM: Step 1 : Start the microprocessor. Step 2 : Move data ax and bcd data to dx and ax Step 3: Perform and operation between o7 and bcd input Step 4 : Move data ax and bcd data bx and ax Step 5 : Perform multiplication by 10 Step 6 : Add the content of B register to accumulator. Step 7: Perform and operation Step 8: Perform addition to get lsb Step 9: Move ax value to bin and 4ch value to a register Step10: Sto

44

FLOW CHART

START

MOVE DATA AX AND BCD DATA TO DX AND AX

PERFORM AND OPERATION BETWEEN O7 AND BCD INPUT

MOVE DATA AX AND BCD DATA BX AND AX

PERFORM MULTIPLICA TION BY 10

YES

NO PERFORM AND OPERATION

PERFORM ADDITION TO GET LSB

MOVE AX VALUE TO BIN AND 4CH VALUE TO A REGISTER

45 END

TABULATION: ADDRES S 1000 1001 1003 1003 1005

MNEMONICS MOV AX,DATA

COMMENT STORE DATA AX

MOV DX,AX

MOVE BCD DATA TO AX

MOV AX,BCD

PERFORM AND OPERATION BETWEEN

AND AX,07H MOV BX,AX

07 AND INPUT BCD MOVE DATA TO BX

MOV AX,BX

MOVE THE BCD DATA TO AX

100D

AND AX,0F0

PERFORM THE AND WITH 0F0H FOR SHIFTING OPERATION

100C 100D 100F 1012

MOV CX,0AH MUL CX

10 IN DECIMAL PERFROM MULTIPILICATION BY 10

1010 1011 1013

ADD AX,BX

1015

MOV BIN,AX

PERFROM ADD OPERATION TO GET LSB MOV RESULT TO BINARY

1017

MOV AH,4CH

MOVE THE VALUE

1019

INT 21H

STOP THE EXECUTION

1005 1007 1009 1008 1009 100B

46

RESULT: BCD to Binary INPUT

OUTPUT

MEMORY LOCATION

CONTENT

MEMORY LOCATION

CONTENT

1001

80

1300

00

1003

80

1301

01

Thus BCD to BINARY conversion was verified. Prepared by Vibha.k 47

(b) CODE CONVERSION FOR BINARY TO BCD:-

ALGORITHM: Step 1 : Start the microprocessor. Step 2: Move data to ax. Step3: Move data of hexadecimal to binary cl register. Step4: Move data ax and bcd data cl and ax. Step5: Perform divison for register. Step6: Perform addition operation for ax. Step7: Perform division to get lsb. Step8: Move ax value to 4ch and binary value to a register Step9: Stop

48

FLOW CHART

START

MOVE DATA TO AX AND AX TO DS

MOVE DATA OF HEXADECIMAL TO BINARY CL REGISTER MOVE DATA AX AND BCD DATA CL AND AX

YES

PERFORM DIVISON FOR REGISTER NO

PERFORM ADDITION OPERATION FOR AX

PERFORM DIVISION TO GET LSB MOVE AX VALUE TO 4CH AND BINARY VALUE TO A REGISTER END 49

TABULATION: ADDRES S 1000 1002 1003 1004 1005 1005 1007

1009 1008 1009 100B 100D 100C 100D 100F

MNEMONICS

COMMENT

MOV AX,DATA

MOVE DATA TO AX REGISTER

MOV DS,AX

MOVE AX DATA TO DS

MOV AX,BIN

MOVE THE BINARY TO AX

MOV CL,64H

MOVE THE DATA OF HEXADECIMAL TO CL REGISTER PERFORM DIVISON OPERATION

DIV CL

MOV BCD+1,AL MOV AL,AH

MOVE DATA TO ACCUMULATOR

MOV AH,00H

MOVE THE DATA TO AH REGISTER MOVE OAH TO CL REGISTER

1012 1010 1011 1014

MOV CL,0AH

DIV CL

1015

MOV CL,04

1017

ROR AL,CL

1019

ADD AL,AH

1021

MOV AH,4CH

1025

INT 21H

PERFORM DIVISON OPERATION FOR CL MOVE 04 TO CL REGISTER ROTATE RIGHT CL TO AL REGISTER PERFORM ADD OPERATION MOVE HEXADECIMAL TO AH REGISTER STOP

50

RESULT: Binary to BCD INPUT

OUTPUT

MEMORY LOCATION

MEMORY LOCATION

CONTENT

CONTENT

1001

80

1300

00

1003

80

1301

01

Thus Binary to BCD conversion was verified

Prepared by Vibha.k

51

Exercise Number: 5

Title of the Experiment: BLOCK DATA TRANSFER IN 8086 Date of the Exercise:

AIM: (a) To write and execute an assemble language program to block transfer in forward order. (b) To write and execute an assemble language program to block transfer in reverse order. APPARATUS REQUIRED: 1. Microprocessor 8086 kit. 2. Manual. a) BLOCK TRANSFER IN FORWARD ORDER ALGORITHM: 1. Start the program 2. Initialization of segment register, counter and program 3. Move a byte from source to destination 4. Upgrade pointer, decrement counter 5. Continue the loop if count is not zero 6. Stop if count is not zero

52

FLOW CHART

Start

Store Source Index values in SI and Destination Source values DI

Store counter in CX

Take a source byte in AL and move it to destination

Increment source pointer,destination pointer,decrement counter

Repeat process until counter is zero

Stop

53

TABULATION: ADDRESS

MNEMONICS

COMMENT

1000

MOV SI,1500

Move pointer to string source

1003

MOV DI,1600

Move the pointer to destination string

1006

MOV CX,05

Count for length of string

1008 100A 100C 100D 100E

MOV AL,[SI] MOV [DI],AL INC SI INC DI DEC CX

Take a source byte in AL Move it to destination Increment source pointer Increment destination pointer Decrement count by 1

100F

JNZ

Continue if count is not zero

1010

INT3

Stop if count is zero

54

RESULT: DATA TRANSFER INPUT

OUTPUT

MEMORY LOCATION

CONTENT

MEMORY LOCATION

CONTENT

1500

01

1600

01

1501

02

1601

02

1502

03

1602

03

1503

04

1603

04

1504

05

1604

05

Thus the block data transfer in forward order is done. 55

b) BLOCK TRANSFER IN REVERSE ORDER ALGORITHM: 1. Start the program and store the source address in the source index. 2. Store the destination address in destination index. 3. Set the counter value. 4. Set directional flag to 1 for decrement order. 5. Store counter value in CX. 6. Repeat the process until CX=0. 7. END of the program.

TABULATION: ADDRESS

MNEMONICS

COMMENT

1000

MOV SI

Store the source address in source index

1001 1002 1003 1004 1005 1006

00 11 MOV DI 04 12 STD

1007 1008 1009 100A 100B 100C

01 MOV CX 05 REPE MOVSB INT3

Store the destination in DI

Set direction flag for decrement Store the value in CX register Repeat the process until CX=0 End the program

56

RESULT: DATA TRANSFER INPUT

OUTPUT

MEMORY LOCATION

CONTENT

MEMORY LOCATION

CONTENT

1100

01

1200

05

1101

02

1201

04

1102

03

1202

03

1103

04

1203

02

1104

05

1204

01

Thus the block data transfer in reverse order is done.

Prepared by K.A.Sunitha 57

Exercise Number: 6 Title of the Experiment: TRAFFIC LIGHT CONTROL USING 8051 Date of the Exercise: Aim: To interface traffic light controller with 8051 microcontroller using 8255. Apparatus required: Microcontroller 8051 kit 8255 peripheral device Traffic Light Controller Procedure: Step 1 Step 2 Step 3 Step 4 Step 5 Step 6

: : : : : :

Connect the 5V supply to the trainer kit. Connect the 26-pin FRC from the kit. Switch ON the power supply. Assemble the program. Execute it and output display by LED. Switch OFF the power supply and remove the connectors.

58

59

Main Program:

Address 9000 9002 9005

Label

Mnemonics MOV A, #80H MOV DPTR,#PPI+3 [email protected],A

Hex-Code 74 80 90 60 03 F0

Comment ALL PORTS AS O/P

For Starting Vehicles N-Direct(St) & Pedest Stopping:

Address 9006 9008 900B 900C

Label

900E 9011 9012 9015

Mnemonics MOV A, #0FH MOV DPTR,#PPI+1 [email protected],A MOV A, #4DH

Hex-Code 74 0F 90 60 01 F0 74 4D

MOV DPTR,#PPI [email protected],A LCALL DELAY LCALL AMBER

90 60 00 F0 12 90 7E 12 90 72

Comment FOR PEDESTRIAN SIGNAL FOR GREEN LEDS IN N-S DIRECTION SEQUENCE DELAY AMBER DELAY

For Stop Vehicles In N-S Direct & Start In E-W Direction:

Address 9018

Label

Mnemonics MOV DPTR,#PPI

Hex-Code 90 60 00

901B

MOV A, #8BH

74 8B

901D 901E 9021

[email protected],A LCALL DELAY LCALL AMBER

F0 12 90 7E 12 90 72

60

Comment FOR STOPPING N-S SIDES STARTING E-W SIDES SEQUENCY DELAY AMBER DELAY

For Straight Right Turn In N-S Sides & Stoping E-W Sides:

Address 9024

Label

Mnemonics MOV A, #49H

Hex-Code 74 49

9026 9029 902A

MOV DPTR,#PPI [email protected],A MOV DPTR,#PPI+2

90 60 00 F0 90 60 02

902D 902F 9030 9033 9035 9036

MOV A, #1H [email protected],A LCALL DELAY MOV A, #0H [email protected],A LCALL AMBER

74 01 F0 12 90 7E 74 00 F0 12 90 72

Comment FOR FREE LEFT IN ALL SIDES & STOPPING IN E-W SIDES FOR RIGHT TURN IN N-S SIDES SEQUENCE DELAY FOR AMBER SIGNAL FOR AMBER DELAY

Stop Right Turn In N-S Sides & Start Right Turn In E-W:

Address 9039

Label

Mnemonics MOV A, #89H

Hex-Code 74 89

903B 903E 903F

MOV DPTR,#PPI [email protected],A MOV DPTR,#PPI+2

90 60 00 F0 90 60 02

9042 9044 9045 9048 904A 904B 904D 9050 9051 9053

MOV A, #2H [email protected],A LCALL DELAY MOV A, #0H [email protected],A MOVA, #30H MOV DPTR,#PPI [email protected],A MOV R1,#4H LCALL DELAYSUB

74 02 F0 12 90 7E 74 00 F0 74 30 90 60 00 F0 79 04 12 9084

61

Comment FOR STOPPING VEHICLES IN N-S SIDES FOR RIGHT TURN IN E-W SIDES SEQUENCE DELAY

FOR AMBER DELAY

For Starting Pedestrain:

Address 9056

Label

Mnemonics MOV A, #0C00H

Hex-Code 74 C0

9058 905B 905C

MOV DPTR,#PPI [email protected],A INC DPTR

90 60 00 F0 A3

905D 905F 9060

MOV A, #0F00H [email protected],A MOV R1,#10H

74 F0 F0 79 10

9062 9065 9067 906A 906B 906D 9070

LCALL DELAYSUB MOVA, #30H MOV DPTR,#PPI [email protected],A MOV R1,#8H LCALL DELAYSUB AJMP CONTINUE

12 90 84 74 30 90 60 00 F0 79 08 12 90 84 01 06

Mnemonics MOV DPTR,#PPI

Hex-Code 90 60 00

MOV A, #39H [email protected],A MOV R1,#8H LCALL DELAYSUB RET

74 39 F0 79 08 12 90 84 22

Mnemonics MOV R1,#040H LCALL DELAYSUB

Hex-Code 79 40 12 90 84

RET

22

Comment FOR STOPPING VEHICLE IN ALL SIDES GREEN SIGNAL FOR PEDESTRAIN DELAY FOR PEDESTRAIN

AMBER DELAY

Amber:

Address 9072

Label

9075 9077 9078 907A 907D

Comment FOR AMBER SIGNAL IN ALL SIDES DELAY COUNT

Delay:

Address 907E 9080 9083

Label

62

Comment DELAY COUNT FOR GREEN & RED SIGNALS

Delay Subroutine:

Address 9084 9086 9088 9089 908A 908C 908D 908E 9090 9091 9093 9094 9096

Label

Mnemonics MOV R2,#0FFH MOV A,#0FFH NOP DEC A JNZ BACK DEC R2 MOV A,R2 JNZ BACK1 MOV A,R1 JZ OUT DEC R1 JNZ BACK2 RET

Hex-Code 7A FF 74 FF 00 14 70 FC 1A EA 70 F6 E9 60 03 19 70 EE 22

Comment

Result: Hence the Traffic Light Controller is interfaced with 8051 microcontroller.

Prepared by G.Y.Rajaa Vikhram 63

Exercise Number: 7 Title of the Experiment: STEPPER MOTOR CONTROL USING 8051 CONTROLLER Date of the Exercise: Aim: To interface stepper motor with 8051 microcontroller Apparatus required: Microcontroller 8051 kit 8255 peripheral device Stepper motor Algorithm: Step 1 Step 2 Step 3 Step 4 Step 5

: : : : :

Step 6

:

Start the microcontroller. Input the key control words 0A, 06, 03, 09. Move to the accumulator and given through output port. Introduce the time delay routine. Using jump condition continue from the beginning to get continuous rotation. Stop.

64

Flow Chart:

(Main Program)

START

Send Control Word to 8255 Port A

Set Accumulator with code sequence for the motor to rotate

Out from Output Port A

Call Delay Subroutine

Repeat Four Times

Jump

END

65

Flow Chart:

(Subroutine Program)

START

Initialize Two Counters

No Operation

Decrement Counters

Jump No Zero

RETURN TO MAIN PROGRAM

66

67

Main Program: Clockwise Direction: Address Label 9000 9003 9005 9006 9009 LOOP1 900B 900C 900F 9011 9012 9015 9017 9018 901B 901D 901E 9021

Mnemonics MOV DPTR, #6003H MOV A, #80H [email protected],A MOV DPTR, #6000H MOV A, #05H [email protected], A LCALL 9024(DELAY) MOV A, #07H [email protected],A LCALL 9024(DELAY) MOV A, #06H [email protected],A LCALL 9024(DELAY) MOV A, #04H [email protected],A LCALL 9024(DELAY) LJMP 9009(LOOP1)

Hex-Code 906003 7480 F0 906000 7405 F0 129024 7407 F0 129024 7406 F0 129024 7404 F0 129024 029009

Comment Control Port of 8255

Mnemonics MOV DPTR, #6003H MOV A, #80H [email protected],A MOV DPTR, #6000H MOV A, #04H [email protected], A LCALL 9024(DELAY) MOV A, #06H [email protected],A LCALL 9024(DELAY) MOV A, #07H [email protected],A LCALL 9024(DELAY) MOV A, #05H [email protected],A LCALL 9024(DELAY) LJMP 9109(LOOP2)

Hex-Code 906003 7480 F0 906000 7404 F0 129024 7406 F0 129024 7407 F0 129024 7405 F0 129024 029109

Comment Control Port of 8255

All bits outputs First Step Sequence Call delay Second step sequence Delay Third step sequence Delay Fourth sequence Delay Repeat

Anti Clockwise Direction: Address Label 9100 9103 9105 9106 9109 LOOP2 910B 910C 910F 9111 9112 9115 9117 9118 911B 911D 911E 9121

68

All bits outputs First Step Sequence Call delay Second step sequence Delay Third step sequence Delay Fourth sequence Delay Repeat

Delay Subroutine: Address 9024 9026 9028 9029 902A 902B 902C 902D 902F 9031

Label

Mnemonics MOV R1, #0AH

LOOP3 LOOP4

MOV A, #40H NOP NOP NOP NOP DEC A JNZ 9028(LOOP4) DJNZ R1,9026(LOOP3) RET

Hex-Code Comment 790A Changing the speed of rotation 7440 00 00 00 00 14 70F9 D9F5 22

Result: Hence the control of stepper motor using 8051 microcontroller is successfully submitted and verified.

Prepared by G.Y.Rajaa Vikhram 69

Exercise Number: 8 Title of the Experiment: TEMPERATURE CONTROL SYSTEM USING 8051 Date of the Exercise:

70

Exercise Number: 9 Title of the Experiment: LCD DISPLAY USING 8051 Date of the Exercise: Aim: To interface LCD with 8051 microcontroller using 8255. Apparatus required: 8051 micro controller kit 1 & 10K TRIM POT 26 PIN FRC 16 PIN RMC 2 PIN MOLEX Procedure: Step 1 Step 2 Step 3 Step 4 Step 5 Step 6

: : : : : :

Connect the 5V power supply to the LCD Interface card. Connect the 26-pin FRC from the kit to the LCD card. Switch ON the power supply. Assemble the program. Execute it and view the display in the LCD. Switch OFF the power supply and remove all the connections.

71

Main Program: Address 8900 8903 8906 8908 8909 890C 890F 8911 8912 8915 8917 8918 891B 891D 891E

Label

Mnemonics LCALL INIT MOV DPTR,#6001H MOV A,#01H MOVX @DPTR,A LCALL LCDENA MOV DPTR,#6001H MOV A,#41H MOVX @DPTR,A LCALL LCD ENA DATA MOV A,#42H MOVX @DPTR,A LCALL LCD ENA DATA MOV A,#43H MOVX @DPTR,A LCALL LCD ENA DATA

Label

Mnemonics MOV DPTR,#6001H MOV A,#0C0H MOVX @DPTR,A LCALL LCDENA MOV DPTR,#6001H MOV A,#31H MOVX @DPTR,A LCALL LCD ENA DATA MOV A,#32H MOVX @DPTR,A LCALL LCD ENA DATA MOV A,#33H MOVX @DPTR,A LCALL LCD ENA DATA LCALL 00BBH

Hex CodeComments 12 89 42 90 60 01 PORT B 74 01 F0 12 89 73 90 60 01 PORT B 74 41 CHAR “A” F0 12 89 83 74 42 CHAR “B” F0 12 89 83 74 43 CHAR “C” F0 12 89 83

Second line: Address 8921 8924 8926 8927 892A 892D 892F 8930 8933 8935 8936 8939 893B 893C 893F

72

Hex Code Comments 90 60 01 PORT B nd 74 C0 2 LINE ADD F0 12 89 73 90 60 01 PORT B 74 31 NUM “1” F0 12 89 83 74 32 F0 12 89 83

NUM “2”

74 33 F0 12 89 83

NUM “3”

12 00 BB

LCD Initialisation:

Address 8942 8945 8947 8948 894B 894D 894E 8951 8953 8954 8957 8959 895A 895D 895F 8960 8963 8965 8966 8969 896B 896C 896F 8972

Label

Mnemonics MOV DPTR, #6003H MOV A, #80H [email protected],A MOV DPTR, #6001H MOV A, #38H [email protected], A LCALL LCDENA MOV A, #38H [email protected],A LCALL LCDENA MOV A, #38H [email protected],A LCALL LCDENA MOV A, #0FH [email protected],A LCALL LCDENA MOV A, #06H [email protected],A LCALL LCDENA MOV A, #01H [email protected],A LCALL LCDENA LCALL LCDENA RET

73

Hex-Code 90 60 03 74 80 F0 90 60 01 74 38 F0 12 89 73 74 38 F0 12 89 73 74 38 F0 12 89 73 74 0F F0 12 89 73 74 06 F0 12 89 73 74 01 F0 12 89 73 12 89 73 22

Comment CWR FOR 8255

PORT B DATA FUNCTION TEST

FUNCTION TEST

FUNCTION TEST

DIS ON/OFF

ENTRY MODE

CLEAR SCREEN

LCDENA:

Address 8973 8976 8978 8979 897B 897C 897F 8982

Label

Mnemonics MOV DPTR, #6002H MOV A, #02H [email protected],A MOV A, #00H [email protected],A LCALL DELAY MOV DPTR,#6001H RET

Hex-Code 90 60 02 74 02 F0 74 00 F0 12 89 93 90 60 01 22

Comment PORT C LCD ENA

Mnemonics MOV DPTR, #6002H MOV A, #03H [email protected],A MOV A, #00H [email protected],A LCALL DELAY MOV DPTR,#6001H RET

Hex-Code 90 60 02 74 03 F0 74 00 F0 12 89 93 90 60 01 22

Comment PORT C ENA DATA

Mnemonics MOV R5, #3FH MOV A,#FFH NOP NOP NOP NOP NOP DEC A JNZ D1 DJNZ, D2 RET

Hex-Code 7D 3F 74 FF 00 00 00 00 00 14 70 F8 DD F4 22

Comment

LCD DISA

PORT B

LCDENADATA:

Address 8983 8986 8988 8989 898B 898C 898F 8992

Label

DISA DATA

PORT B

DELAY ROUTINE:

Address Label 8993 8995 D2 8997 D1 8998 8999 899A 899B 899C 899D 899F 89A1

74

Result: Hence the LCD display is interfaced with 8051 microcontroller.

Prepared by G.Y.Rajaa Vikhram 75

Exercise Number: 10 Title of the Experiment: SEVEN SEGMENT DISPLAY USING nuvoTON BOARD Date of the Exercise: AIM: To interface a seven segment display with a NUC140 nuvoTON board. APPARATUS REQUIRED: NUC140 nuvoTON board, 7 segment display

PROCEDURE:

76

CODE: #include "NUC1xx.h" void clr_segment(void) { unsigned char i; for(i=0; i<4; i++) { GPIOC->DOUT &= ~(1<<(4+i)); } } void show_segment(unsigned char n, unsigned char number) { unsigned char i; unsigned char number__[10] = {0x82 ,0xEE, 0x07, 0x46, 0x6A, 0x52, 0x12, 0xE6, 0x02, 0x62}; for(i=0; i<8; i++) { if((number__[number_]&0x01)==0x01) GPIOE->DOUT |= (1<DOUT &= ~(1<>1; } GPIOC->DOUT |= (1<<(4+n)); }

Prepared by K. A. Sunitha

77