8051 Basic & Interfacing

63
Dr. Mahalingam College of Engineering and Technology Pollachi – 642003 Department of Electronics and Communication Engineering EC1307 - MICROPROCESSOR & ITS APPLICATIONS LAB LAB MANUAL ACTIVITY NAME OF FACULTY DESIGNATION SIGNATURE PREPARED BY Ms. P. SENTHIL AMIRTHAM LECTURER 1 MCET/BEC/LM/

Transcript of 8051 Basic & Interfacing

Page 1: 8051 Basic & Interfacing

Dr. Mahalingam College of Engineering and

Technology

Pollachi – 642003

Department of Electronics and Communication Engineering

EC1307 - MICROPROCESSOR & ITS APPLICATIONS LAB

LAB MANUAL

ACTIVITY NAME OF FACULTY DESIGNATION SIGNATURE

PREPARED

BYMs. P. SENTHIL AMIRTHAM LECTURER

APPROVED

BY

PROF.K.R.RADHA

KRISHNANHOD/ECE

ISSUED BYPROF.P.CHANDRASEKAR

MR/ISO

1

MCET/BEC/LM/

Page 2: 8051 Basic & Interfacing

SUBJECT : EC1307 MICROPROCESSOR & ITS

APPLICATIONS LABORATORY

SEMESTER : V

BRANCH : ECE

INDEX

S.No. LIST OF EXPERIMENT PAGE NO

1 Programs for 8/16 bit arithmetic operations(Using 8085)

2 Programs for sorting & searching (Using 8085,8086)

3 Programs for String manipulation operations (Using 8086)

4 Programs for Digital clock & stop watch (Using 8086)

5 Interfacing ADC & DAC

6Parallel communication between two kits using Mode1 and

Mode 2 of 8255

7 Interfacing and programming of 8259,8279

8 Serial communication between two MP kits using 8251,8253

9 Interfacing & programming of stepper motor and DC motor

control10 Programming using Arithmetic, Logical and bit manipulation

instructions of 8051 microcontroller

11Programming & verifying Timer, Interrupts and UART

operations in 8031/51 microcontroller

12 Communication between 8051 microcontroller kit & PC

2

Page 3: 8051 Basic & Interfacing

EX.NO.1 PROGRAMS FOR 8/16 BIT ARITHMETIC OPERATIONS(8085)

i) 8 – Bit Addition:

MVI D,00

LDA add1

MOV B,A

LDA add2

ADD B

JNC Loop1

INR D

Loop1: STA add3

MOV A,D

STA add4

HLT

Result:

Add1 : data1

Add2 : data2

Add3 : Result

Add4 : Carry

ii) 16-bit Addition:

MVI B,00

LHLD add1

XCHG

LHLD add3

DAD D

JNC Loop1

INR B

Loop1: SHLD add5

XCHG

SHLD add7

HLT

3

Page 4: 8051 Basic & Interfacing

Result :

Add1 : Lower order byte of data 1

Add2 : Higher order byte of data 1

Add3 : Lower order byte of data 2

Add4 : Higher order byte of data 2

Add5 : Lower order byte of Result

Add6 : Higher order byte of Result

Add7 : Carry

iii) 8 –bit Subtraction:

MVI D,00

LDA add1

MOV B,A

LDA add2

SUB B

JNC Loop1

INR D

CMA

INR A

Loop1: STA add3

MOV A,D

STA add4

HLT

Result:

Add1 : data1

Add2 : data2

Add3 : Result

Add4 : Borrow

4

Page 5: 8051 Basic & Interfacing

iv) 16-bit Subtraction:

MVI B,00

LHLD add1

XCHG

LHLD add3

MOV A,E

SUB L

STA add5

MOV A,D

SBB H

JNC Loop1

INR B

Loop1: STA add6

MOV A,B

STA add7

HLT

Result:

Add1 : Lower order byte of data 1

Add2 : Higher order byte of data 1

Add3 : Lower order byte of data 2

Add4 : Higher order byte of data 2

Add5 : Lower order byte of Result

Add6 : Higher order byte of Result

Add7 : Borrow

5

Page 6: 8051 Basic & Interfacing

v) 8 – bit multiplication:

MVI D,00

LDA add1

MOV B,A

LDA add2

MOV C,A

MVI A,00

Loop2:ADD B

JNC Loop1

INR D

Loop1: DCR C

JNZ Loop2

STA add3

MOV A,D

STA add4

HLT

RESULT:

Add1 : data1

Add2 : data2

Add3 : Lower order byte of Result

Add4 : Higher order byte of Result

vi) 16-bit Multiplication :

LXI B,0000

LHLD add1

XCHG

LHLD add2

SPHL

LXI H,0000

Loop2: DAD SP

JNC Loop1

INX B

6

Page 7: 8051 Basic & Interfacing

Loop1: DCX D

MOV A,E

ORA D

JNZ Loop2

SHLD add5

MOV L,C

MOV H,B

SHLD add7

HLT

Result :

Add1 : data 1 Lower order byte of data 1

Add2 : data 1 Higher order byte of data 1

Add3 : data 2 Lower order byte of data 2

Add4 : data 2 Higher order byte of data 2

Add5 : Lower order byte of Result

Add6 : Lower order byte of Result

Add7 : Higher order byte of Result

Add8 : Higher order byte of Result

1 word = 16 bits &

1 byte = 8 bits

vii) 8 – bit Division:

MVI D,00

LDA add1

MOV B,A

LDA add2

Loop2 :CMP B

JC Loop 1

SUB B

INR D

JMP Loop 2

7

Page 8: 8051 Basic & Interfacing

Loop1: STA add3

MOV A,D

STA add4

HLT

Result:

Add1: dividend

Add2 : divisor

Add3 : Remainder

Add4 : Quotient

viii) 16 – bit division:

LXI B,0000

LHLD add1

XCHG

LHLD add3

L2 : SPHL

MOV A,E

SUB L

MOV L,A

MOV A,D

SBB H

JC L1

INX B

MOV H,A

JMP L2

LXI H,0000

DAD SP

SHLD add5

MOV H,B

8

Page 9: 8051 Basic & Interfacing

MOV L,C

SHLD add7

HLT

RESULT:

Add1: dividend - LOB

Add2 : dividend - HOB

Add3: divisor - LOB

Add4 : divisor - HOB

Add5 : Remainder - LOB

Add6 : Remainder - HOB

Add7 : Quotient - LOB

Add8 : Quotient - HOB

ix) Conversion of a Hexadecimal number to a BCD number:

LDA add1

MVI B,00

MVI C,64

MVI D,0A

MVI H,00

Loop2 : CMP C

JC Loop1

SUB C

INR B

JMP Loop2

Loop1 : CMP D

JC Loop3

SUB D

INR D

JMP Loop1

9

Page 10: 8051 Basic & Interfacing

MOV L,A

MOV A,D

RLC

RLC

RLC

RLC

ADD L

STA add2

MOV A,B

STA add3

HLT

RESULT:

Add1: hexadecimal number

Add2: lower order byte of BCD

Add 3: higher order byte of BCD

x) Conversion of a BCD number to hexadecimal number:

MVI H,00

MVI L,0A

MOV B,A

ANI 0F

MOV E,A

MOV A,B

ANI F0

RRC

RRC

RRC

RRC

MOV C,A

MVI A,00

Loop2:ADDC

DCR L

JNZ Loop2

ADD E

10

Page 11: 8051 Basic & Interfacing

STA add2

HLT

RESULT:

Add1: data1(BCD)

Add2: result (Hexa)

xi) Convert an array of ASCII numbers into their equivalent character :

LXI H, add1

MVI B, count

LXI D,add2

Loop1 : MOV A,M

CALL Conversion

STAX D

INX H

INX D

DCR B

JNZ Loop1

HLT

Conversion : SUI 30H

CMP 09

JC Loop2

SUI 07

Loop2 : RET

xii) Conversion of BCD/hexa number to ASCII:

LDA add1

MOV B,A

ANI 0F

11

Page 12: 8051 Basic & Interfacing

MOV C,A

MOV A,B

ANI F0

RRC

RRC

RRC

RRC

CALL Conversion

STA add2

MOV A,C

CALL Conversion

STA add3

HLT

Conversion: CPI 0A

JC Loop1

ADI 07

Loop1 : ADI 30

RET

RESULT :

Add1: Packed BCD number

Add2: ASCII of HOB

Add3: ASCII of LOB

xiii) Moving a block of data from one location to another:

LXI H, add1

LXI B, add2

MVI D, count

Loop1: MOV A,M

12

Page 13: 8051 Basic & Interfacing

STAX B

INX H

INX B

DCR D

JNZ Loop1

HLT

RESULT :

Add1 : Starting add of source

Add2: Starting add of destination

xiv) Adding an array of data:

LXI H, add

MVI D,00

MOV C,M

INX H

MOV A,M

Loop1: INX H

MOV B,M

ADD B

JNC Loop

INR D

Loop : DCR C

JNZ Loop1

STA add1

MOV A,D

STA add2

HLT

13

Page 14: 8051 Basic & Interfacing

EX.NO.2 PROGRAMS FOR SORTING/ SEARCHING (USING

8085,8086)

i) Sorting of an array of 8-bit numbers using 8085

LXI H,add1

MOV B,M

MOV C,B

Loop3: LXI H,add1

MOV D,B

Loop2: MOV A,M

INX H

MOV B,M

CMP B

JC / JNC Loop1

MOV M,A

DCX H

MOV M,B

INX H

Loop1: DCR D

JNZ Loop2

DCR C

JNZ LooP3

HLT

ii) Searching a number in an array of data using 8085

MVI D,00

LXI H, add

MOV C,M

INX H

MOV B,M

Loop2: INX H

14

Page 15: 8051 Basic & Interfacing

MOV A,M

CMP B

JNZ Loop1

INR D

Loop1: DCR C

JNZ Loop2

MOV A,D

STA add

HLT

iii) Sorting an array of 8-bit numbers using 8086

MOV SI, add

MOV BL, [SI]

MOV DL,BL

Loop3: MOV SI,add2

MOV DH, BL

Loop2: MOV AL,[SI]

INC SI

MOV BH,[SI]

CMP AL,BH

JC/JNC Loop1

MOV [SI],AL

DEC SI

MOV [SI],BH

INC SI

Loop1: DEC DH

JNZ Loop2

DEC DL

JNZ Loop3

HLT

15

Page 16: 8051 Basic & Interfacing

iv) Sorting an array of 16-bit number using 8086

MOV SI, add

MOV BL, [SI]

MOV DL,BL

Loop3: MOV SI,add2

MOV DH, BL

Loop2: MOV AX,[SI]

INC SI

INC SI

MOV CX,[SI]

CMP AX,BX

JC/JNC Loop1

MOV [SI],AX

DEC SI

DEC SI

MOV [SI],CX

INC SI

INC SI

Loop1: DEC DH

JNZ Loop2

DEC DL

JNZ Loop3

HLT

16

Page 17: 8051 Basic & Interfacing

v) Searching For A Number Using 8086

MOV DI, starting address of the string

CLD

MOV AL, number to be searched

MOV CX, count

REPNE SCASB

JNZ LOOP1

DEC DI

MOV [2000H], DI; Displays the location of the searched data if found in the string at

the memory location 2000H

JMP LOOP2

LOOP1: MOV [2000H], 0000H ; Displays 0000H at the memory location 2000H, if

the

Searched data is not found in the string

LOOP2: HLT

17

Page 18: 8051 Basic & Interfacing

EX.NO. 3 PROGRAMS FOR STRING MANIPULATION OPERATIONS

(USING 8086)

a) Program to move a string of 16-BIT data from locations in data

segment to locations in extra segment:

MOV CX, COUNT

MOV DI,OFFSET OF DESTINATION

MOV SI, OFFSET OF SOURCE

REP MOVSW

HLT

b) Program to compare whether two strings of data are equal. If so, store

AAH at location 5000h, if not store DDH:

MOV CX, COUNT

MOV DI, OFFSET OF STRING 1

MOV SI, OFFSET OF STRING2

REPE CMPB

JNZ LOOP

MOV [5000H], AAH

JMP END

LOOP: MOV [5000H], DDH

END: HLT

18

Page 19: 8051 Basic & Interfacing

EX. NO. 4 PROGRAMS FOR DIGITAL CLOCK AND STOP WATCH

(USING 8086)

Program that places a message on the screen every 10 seconds, using int

1ah;

CODE SEGMENT

TIMEDELAY:

MOV SP,1000H

MOV DI,10XD

TIME OUT:

MOV AH,00H

INT 1AH

MOV BX,DX

TIMER:

MOV AH, 00H

INT 1AH

SUB DX, BX

CMP DX, 182XD

JC TIMER

MOV AH, 09H

CS MOV DX,MSG

INT 21H

DEC DI

JNZ TIMEOUT

MOV AX,4C00H

INT 21H

MSG:

DB 'TEN MORE SECONDS HAVE PASSED $'

CODE ENDS

19

Page 20: 8051 Basic & Interfacing

20

Page 21: 8051 Basic & Interfacing

EX.NO.5 ADC & DAC INTERFACING WITH 8051

ADC Interfacing

MOV DPTR, #add1

MOV A, #data1

MOVX @DPTR,A

MOV A,#data2

MOVX @DPTR,A

MOV DPTR,#add2

MOV A,#data3

MOVX @DPTR,A

MOV A,#data4

MOVX @DPTR,A

HERE : SJMP HERE

Add1 - address to select the channel, send ALE & OE signals

Add2 - address to send the SOC signal

Data1 - data to select the channel, ALE low & OE high

Data2 - data to select the channel, ALE high & OE high

Data3 - send SOC high D0 - high

Data4 - send SOC low D0 - low

21

Page 22: 8051 Basic & Interfacing

Channel No. Data to make Data to make

ALE low & OE high ALE high & OE high

CH0 10 18

CH1 11 19

CH2 12 1A

CH3 13 1B

CH4 14 1C

CH5 15 1D

CH6 16 1E

CH7 17 1F

22

Page 23: 8051 Basic & Interfacing

DAC Interfacing

i) Program to generate a square wave:

START: MOV DPTR,#00

MOV A,#00

MOVX @DPTR,A

LCALL DELAY

MOV A,#FF

MOVX @ DPTR,A

LCALL DELAY

SJMP START

DELAY: MOV R1,#FF

L2: MOV R2,#FF

L1: DJNZ R2,L1

DJNZ R1,L2

RET

ii) Program to generate a saw tooth wave

MOV DPTR,#add1

MOV A,#00

LOOP : MOVX @DPTR,A

INC A

SJMP LOOP

23

Page 24: 8051 Basic & Interfacing

EX.NO.6 PARALLEL COMMUNICATION BETWEEN TWO MP

KITS USING MODE1 & MODE2 OF 8255

MODE1:

TRANSMITTER:

MVI A,A0 ; Control word to set PA as output port in mode1

OUT CR

LOOP: IN PC ; Checking for the status of OBF

ANI 90

JZ LOOP

MVI A,DATA; Transfer data

OUT PA

HLT

RECEIVER:

MVI A,B0 ; Control word to set PA as input port in mode1

OUT CR

LOOP: IN PC ; Checking for the status of IBF

ANI 20

JZ LOOP

IN PA ; Get data

STA ADD

HLT

24

Page 25: 8051 Basic & Interfacing

MODE 2:

KIT 1:

MVI A,C0 ;Control word to set PA in mode2

OUT CR

LOOP: IN PC ; Check the status of OBF

ANI 90

JZ LOOP

MVI A, DATA ; Transfer data

OUT PA

LOOP1: IN PC ; Check the status of IBF

ANI 20

JZ LOOP1

IN PA ; Get data

STA ADD

HLT

KIT2:

MVI A, C0 ; Control word to set PA in mode2

OUT CR

LOOP: IN PC ; check the status of IBF

ANI 20

JZ LOOP

IN PA ; get data

STA ADD

LOOP1: IN PC ; Control word to set PA in mode2

ANI 90

JZ LOOP1

MVI A, DATA ; Transfer data

OUT PA

HLT

25

Page 26: 8051 Basic & Interfacing

EX. NO. 7 INTERFACING & PROGRAMMING 8279,8259

Interfacing 8279 with 8085 microprocessor

Program to roll a message:

START: MVI A,01 ;Control word to set keyboard & display modes

OUT CR of 8279

MVI A,CC ;Control word to clear display

OUT CR of 8279

MVI A,90 ;Control word to write display RAM

OUT CR of 8279

LXI H, Address ;loading HL Rp with the starting address of the

Loopup table.

MVI B, Count ;No. of characters to be displayed

LOOP: MOV A,M ; get the data & send it to 8279

OUT DR of 8279

CALL DELAY

INX H

DCR B

JNZ LOOP

JMP START

DELAY: LXI D,COUNT

LOOP1: DCX D

MOV A,D

ORA E

JNZ LOOP1

RET

26

Page 27: 8051 Basic & Interfacing

Interfacing 8259 with 8085 microprocessor

Initialize 8259 with the following specifications:

ICW4 needed, single 8259, Interval of ------(8085), Edge triggered mode, Vector

address(8085)/ Type number(8086) of IR0 ------, ------- mode, Normal EOI, Non-

buffered mode, Not special fully nested mode, Mask all interrupts except ---------.

A0 – Address with A0 = 0

A1 – Address with A0 = 1

Using 8085:

MVI A, ICW1

OUT A0

MVI A,ICW2

OUT A1

MVI A,ICW4

OUT A1

MVI A,OCW1

OUT A1

HLT

ISR: MVI A,OCW2 ; Non-specific EOI command

OUT A0

HLT

27

Page 28: 8051 Basic & Interfacing

Using 8086:

MOV AL,ICW1

OUT A0,AL

MOV AL,ICW2

OUT A1,AL

MOV AL,ICW4

OUT A1,AL

MOV AL,OCW1

OUT A1,AL

STI

HLT

Vector Table: offset address - Interrupt type * 4

0000: offsetaddress - Segment Address : Offset address of the ISR

ISR: MOV AL,OCW2

OUT A0,AL

HLT

28

Page 29: 8051 Basic & Interfacing

EX. NO. 8 SERIAL COMMUNICATION BETWEEN TWO

KITS(8085/8086) USING 8251,8253

TRANSMITTER END:

MVI A,36 ; Control word for 8253

OUT CR OF 8253

MVI A,0A ; LSB Count for Counter0

OUT Counter 0 of 8253

MVI A,00 ; MSB Count for Counter0

OUT Counter 0 of 8253

MVI A,4E ; Mode word

OUT CR of 8251

MVI A,37 ; Control word

OUT CR of 8251

LOOP: IN CR of 8251 ; Checking for the status of TXE signal

ANI 04

JZ LOOP

MVI A,data ; Transmit data

OUT DR of 8251

HLT

29

Page 30: 8051 Basic & Interfacing

RECEIVER END:

MVI A,36 ; Control word for 8253

OUT CR OF 8253

MVI A,0A ; LSB Count for Counter0

OUT Counter 0 of 8253

MVI A,00 ; MSB Count for Counter0

OUT Counter 0 of 8253

MVI A,4E ; Mode word

OUT CR of 8251

MVI A,37 ; Control word

OUT CR of 8251

LOOP: IN CR of 8251 ; Checking for the status of RXRDY signal

ANI 02

JZ LOOP

IN DR of 8251 ; receive data

STA address ; Save the received data in a memory location

HLT

30

Page 31: 8051 Basic & Interfacing

EX. NO. 9 INTERFACING & PROGRAMMING OF STEPPER MOTOR &

DC MOTOR USING 8051

Interfacing stepper motor

Start : MOV DPTR, # add1

MOV R0,#04

L4: MOVX A,@DPTR

PUSH DPH

MOV DPL

MOV DPTR, #add1

MOV R2, #d1

L3: MOV R1,#d2

L2: MOV R3,#d3

L1: DJNZ R3,L1

DJNZ R1,L2

DJNZ R2,L3

MOVX @DPTR,A

POP DPL

POP DPH

INC DPTR

DJNZ R0,L4

SJMP START

Add1 – address of data

For example : 4500

4500 : 09

4501 : 05

4502 : 06

4503 : 0A

d1,d2,d3 - data for delay

31

Page 32: 8051 Basic & Interfacing

Interfacing DC motor

MOV DPTR, #FF08

MOV A,#80

MOV @DPTR,A

L1: MOV DPTR,#4200

MOVX A,@DPTR

MOV DPTR, #FF0D

MOVX @DPTR,A

MOV DPTR, #FF08

MOV A,#40

MOVX @DPTR,A

MOV A,#00

MOVX @DPTR,A

MOV DPTR, #4201

MOVX A, @DPTR

MOVX DPTR, #FF0D

MOVX @DPTR,A

MOV DPTR, #FF0E

MOV A, #80

MOVX @DPTR, A

MOV A,#00

MOVX @DPTR, A

SJMP L1

32

Page 33: 8051 Basic & Interfacing

EX.NO.10 PROGRAMMING USING ARITHMETIC, LOGICAL AND BIT

MANIPULATION INSTRUCTIONS OF 8051

MICROCONTROLLER

a) Program to count the number of even & odd numbers in an array of

numbers:

MOV DPTR, #4500H

MOVX A, @DPTR

MOV R0, A

MOV R1,#00H

MOV R2,#00H

LOOP2: INC DPTR

MOV A, @DPTR

MOV B, 02H

DIV AB

CJNE B,#00,LOOP

INC R1

SJMP LOOP1

LOOP: INC R2

LOOP1: DJNZ R0,LOOP2

MOV DPTR,#5000h

MOV A,R1

MOVX @DPTR,A

INC DPTR

MOV A,R2

MOVX @DPTR,A

HERE: SJMP HERE

33

Page 34: 8051 Basic & Interfacing

b) Program to separate a byte into its lower & upper nibble:

MOV DPTR,#4500H

MOVX A,@DPTR

MOV R0,A

ANL A,#F0H

RL

RL

RL

RL

MOV R1,A

MOV A,R0

ANL A,#0FH

INC DPTR

MOVX @DPTR,A

MOV A,R1

INC DPTR

MOVX @DPTR,A

HERE: SJMP HERE

34

Page 35: 8051 Basic & Interfacing

c) Program to see if bits 5 & 6 of memory location 5000H are 1. If not

make so and save it at memory location 5001H:

MOV DPTR,#5000H

MOVX A,@DPTR

MOV B.A

JB B.5H, LOOP1

SETB B.5

LOOP1: JB B.6,LOOP2

SETB B.6

LOOP2: MOV A,B

INC DPTR

MOVX @DPTR,A

HERE: SJMP HERE

35

Page 36: 8051 Basic & Interfacing

EX.NO.11 PROGRAMS TO VERIFY TIMER, INTERRUPTS & UART

OPERATIONS IN 8031 MICROCONTROLLER

a) Program to generate a square wave of frequency --------.

Steps to determine the count:

Let the frequency of sqaurewave to be generated be Fs KHz.

And the time period of the squarewave be Ts Sec.

Oscillator Frequency = 11.0592MHz.

One machine cycle = 12 clock periods

Time taken to complete one machine cycle=12*(1/11.0592MHz)=

1.085microsec.

Y(dec) = (Ts/2)/(1.085microsec)

Count(dec) = 65536(dec) – Y(dec)

= Count(hexa)

MOV TMOD,#10h ; To select timer1 & mode1 operation

L1: MOV TL1,#LOWERORDER BYTE OF THE COUNT

MOV TH1,#HIGHER ORDER BYTE OF THE COUNT

SETB TR1 ; to start the timer (TCON.6)

BACK: JNB TF1,BACK ; checking the status of timerflag1(TCON.7) for

overflow

CPL Px.x ; get the square wave through any of the portpins

; eg. P1.2 (second bit of Port 1)

CLR TR1 ; stop timer

CLR TF1 ; clear timer flag for the next cycle

SJMP L1

36

Page 37: 8051 Basic & Interfacing

b) Program to transfer a data serially from one kit to another.

Transmitter:

MOV TMOD,#20H ; Mode word to select timer1 & mode 2

MOV TL1,#FDH ; Initialize timer1 with the count

MOV TH1,#FFH

MOV SCON,#50H ; Control word for serial communication

to

to select serial mode1

SETB TR1 ; Start timer1

MOV A,#06h

MOV SBUF,A ; Transfer the byte to be transmitted to

serial

Buffer register.

LOOP: JNB TI, LOOP ; checking the status of Transmit

interrupt

flag

CLR TI

HERE: SJMP HERE

Receiver:

MOV TMOD,#20H

MOV TL1,#FDH

MOV TH1,#FFH

MOV SCON,#50H

SETB TR1

LOOP: JNB RI,LOOP

MOV A,SBUF

MOV DPTR,#4500H

MOVX @DPTR,A

CLR RI

HERE: SJMP HERE

37

Page 38: 8051 Basic & Interfacing

EX.NO.12 COMMUNICATION BETWEEN 8051 MICROCONTROLLER

KIT & PC

SERIAL COMMUNICATION

8051>H

HELP MENU

D Display data, program, internal, bit memory or registers

E Edit data, program, internal, bit memory or registers

S Single step from specified address, press SP to terminate

G Execute the program till user break

B Set address till where the program is to be executed

C Clear break points

F10 Key followed by 4 key at the PC to upload data to a file (DOS)

T Test the onboard peripherals

: Download a file from PC mem to the SDA-SI-MEL kit (DOS)

A Assembler

Z Disassembler

TEST FOR ONBOARD PERIPHERALS

For SDA SI-MEL kit, following menu is displayed on pressing the option "T"

8051>T

ALS-SDA SI-MEL Kit Test monitor

1. Test internal Data RAM

2. Test external Data Memory (U6)

3. Test external Data memory (U7)

4. 8255 loop test

38

Page 39: 8051 Basic & Interfacing

5. Test 8253

6. Exit

Select (1-6):

Suppose the user presses the key '1', following message is displayed if the internal

data RAM is OK.

Testing internal data RAM: Pass

After displaying the message, the menu is displayed once again waits for user to enter

a key

EDITING MEMORY COMMAND:

8051>E

EDIT (R,B,M,P,D)…D - EXTERNAL DATA RAM

Enter STA address = 0400

0400 = 7F:55 Press 'N' key to go to the next address

0401 = D5:66

0402 = D3:77

0403 = 73:88

0404 = 6F:12

0405 = CB:01

0406 = A7:02 Press 'P' key to go to the previous address

0407 = 6F:03

0408 = 7B:04

0409 = 29:05

040A = 6F:06

040B = 73:07

040C = FF:08

040D = 7D:09 Press 'CR' key to have the same address

040E = 09:90 Press 'ESC' Key to abort the command

39

Page 40: 8051 Basic & Interfacing

8051>E

EDIT (R,B,M,P,D)…B - BITS

Enter STA address = 00

00 = 0:1

01= 0:1

02 = 0:0

03 = 0:1

03 = 1:

03 = 1:

02 = 0:

8051>E

EDIT (R,B,M,P,D)…R- REGISTERS

ACC = 00:33

PSW = 00:44

DPH = 00:55

DPL = 00:00

DPL = 00:00

8051>E

EDIT (R,B,M,P,D)…-P = PROGRAM CODE

8000 = FF:78

8001 = FF:10

8002 = FF:79

8003 = FF:20

8004 = FF:7A

8005 = FF: 12

8007 = FF : 00

8008 = FF : 03

8009 = FF : 0F

8051>E

EDIT (R,B,M,P,D)…-M - INTERNAL RAM

40

Page 41: 8051 Basic & Interfacing

0000 = 00 : 12

0001 = 00 : 34

0002 = 00 : 00

DISPLAY COMMAND

8051>D

EDIT (R,B,M,P,D)…-EXTERNAL DATA RAM

Enter STA address = 0400

Enter END address = 040F

0500 55 66 77 88 12 01 02 03 04 05 06 07 08 09 04 D7

SETTING BREAK COMMAND :

8051>B

BR _ NO: R

BR_ADD 0000

ERROR! ONLY A BREAKS ALLOWED

8051>B

BR _ NO: 0

ERROR! BREAK NUMBERS MUST BE BETWEEN 1 & 8

CLEAR BREAK COMMAND:

8051>C

BR_N0:A Clears all the break point set by the user

8051>C

BR_N0:1 Clears the break point number 1

41

Page 42: 8051 Basic & Interfacing

PROGRAMME EXECUTION COMMAND:

8051>G

PROGRAM EXECUTION

ENTER START ADDRESS = 8000

ACC PSW DPH DPL PCH PCL SP B R0 R1 R2 R3 R3 R4 R5 R6 R7

33 44 55 00 10 34 00 00 00 00 00 00

ASSEMBLE MEMORY COMMAND

8051>A

ENTER START ADDRESS = 8000

DISASSEMBLE MEMORY COMMAND

8051>Z

42