Vous êtes sur la page 1sur 67

SR NO LIST OF EXPERIMENT DATE MARKS

1 ADD TWO NUMBER 9/8/18


MUL TIPLICATIO
2 9/8/18
AND DIVISION
3 COMPLEMENT 9/8/18
ADD 8 BIT NUMBER FROM CODE
4 9/8/18
MEMORY
REPEAT ABOVE QUE AND STORE
5 9/8/18
RESULT IN EXTERNAL MEMORY
6 ADD TWO 16 BIT NUMBER 16/8/18
7 SUBTRACTION THAT HAS BORROW 16/8/18
8 BCD OF HEXADECIMAL 16/8/18
ADD TWO 8 BIT AND STORE IN
9 16/8/18
HEXADECIMAL
10 SUM AND AVG OF AN ARRAY 16/8/18
11 SUM OF ARRAY THAT HAS 8 BIT 30/8/18
12 MOVE A BLOCK OF MEMORY 30/8/18
MOVE A BLOCK OF MEMORY IN
13 30/8/18
REVERSE ORDER
MOVE BLOCK OF MEMORY FROM
14 30/8/18
30H-39H TO 35H-3EH
FIND SOME OF ARRAY AND IF
15 CARRY MULTIPLY IT WITH RESULT 6/9/18
OF SUM
16 MUL 16 BIT WITH 8 BIT 6/9/18
17 FACTORIAL 5(5!) 6/9/18

18 SQURE OF 16 BIT NUMBER 6/9/18

19

20
21
22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39
1).

Question:
Add two 8 bit numbers from 40h and 45h, and store the 16 bit result in 50h (MSB), 51h (LSB)

Code:
ORG 0h

MOV 40H, #0FFh

MOV 45H, #0AFh

MOV A, 40h

MOV B, 45h

ADD A, B

MOV 51h, A

JNC X

MOV 50H, #01H

X:

END

Result:

Conclusion:
After adding two 8 bit numbers when the answer is having a carry it triggers the carry flag and with JNC
and JC functions we can access carries.
2).

Question:
Multiply two 8 bit numbers from 40h and 45h, and store the 16 bit result in 50h (MSB), 51h
(LSB)

Code:
ORG 0h

MOV 40H, #0FFh

MOV 45H, #0AFh

MOV A, 40h

MOV B, 45h

MUL AB

MOV 51h

,A

MOV 50H, B

END

Result:

Conclusion:
When we multiply two 8 bit numbers it always gives a 16 bit number such that the first 8 bit stores in B
register and last 8 bit stores in a register.

2).

Question:
Divide two 8 bit numbers from 40h and 45h, and store the 16 bit result in 50h (MSB), 51h (LSB)

Code:
ORG 0h

MOV 40H, #0FFh

MOV 45H, #0AFh

MOV A, 40h

MOV B, 45h

DIV AB

MOV 51h, A

MOV 50H, B

END

Result:

Conclusion:
When we divide two hexadecimal 8 bit numbers the quotient stores in a register and remainder
stores in B register.
3).

Question:
Find the complement of the number stored in 40h and store the result in 50h.

Code:
ORG 0h

MOV 40H, #0BCh

MOV A, 40h

CPL A

MOV 50H, A

END

Result:

Conclusion:
We can find the complement of a number stored in a particular address using CPL function
whose result gets stored in Accumulator.
4).

Question:
ADD two 8 bit numbers from code memory, and store the result in address 40h.

Code:
ORG 0h

MOV DPTR, #1000H

MOV A, #0H

MOVC A,@A+DPTR

MOV B, A

MOV A, #010H

MOVC A,@A+DPTR

ADD A, B

MOV 40H, A

END

Result:

Conclusion:
We can add two numbers from the code memory by using MOVC command and then for
address we can use DPTR command also.
5)

Question:
Repeat the Question4 and store the result in external memory 0000h.

Code:
ORG 0h

MOV DPTR, #1000H

MOV A, #0H

MOVC A,@A+DPTR

MOV B, A

MOV A, #010H

MOVC A,@A+DPTR

ADD A, B

MOV DPTR, #0000H

MOVX @DPTR, A

END

Result:

Conclusion:
For storing the value in external memory we can use MOVX command.
6).

Question:
Add two 16 bit numbers that has stored in internal memory 30,31,32,33 then store the
24bit result in addresses 36, 35, 34. (Results may be in 24 bit size).

CODE:
ORG 0h ORG 0h

MOV 030h, #0ABH MOV 030h, #0ABH


MOV 031h, #0CDH MOV 031h, #0CDH

MOV 032h, #012H MOV 032h, #012H


MOV 033h, #034H MOV 033h, #034H

MOV A,031H MOV A,031H


MOV B,033H MOV B,033H

ADD A,B ADD A,B


MOV 36H, A MOV 36H, A

JNC X MOV A, 030H


MOV 35H, #01H MOV B, 032H
X:
ADDC A,B
MOV A, 035H MOV 35H, A
MOV B, 030H
JNC Y
ADD A,B MOV 34H, #01H
Y:
MOV B, 032H
END
ADD A,B
MOV 35H, A

JNC Y
MOV 34H, #01H
Y:

END
Conclusion:
Add two 16 biota numbers with the help of ADDC command or without ADDC
command.
7)

Question:
Subtract two 8 bit numbers that has borrowed.

Code:
ORG 00H

MOV A, #0AAh

MOV B, #0BCh

SUBB A, B

CPL A

MOV B, #01h

ADD A, B

END

Result:

Conclusion:
Here we are using two’s complement for subtraction of two numbers.
8)

Question:
Find BCD of hexadecimal number.

Code:
ORG 00H

MOV A, #0aAh

DA A

END

Result:

Conclusion:
DA commands add 6 to invalid bad numbers to make it valid.
9).

Question:
Add two BCD numbers.

Code:
ORG 00H

MOV A, #72h

MOV B, #42h

ADD A, B

DA A

MOV 10H, A

JNC X

ADD A, #01H

X:

END

Result:

Conclusion:
Here we added two bad numbers.
10)

Question:
Find the sum and average of an array starting from address 40h to 49h.

Code:
ORG 00H

MOV A, #00H

MOV R0, #0AH

MOV B, #0AH

MOV R1, #040H

MOV A, #00H

X:

ADDC A,@R1

INC R1

DJNZ R0, X

MOV R0, A

DIV AB

END

Result:
Conclusion:
With the help of DJNZ, commands we are able to loop over add the numbers stored in
array and by dividing it we get the average.
11)

Question:
Find the sum of an array (50h to 59h), that has 8 bit numbers, and stores the result in
address 61h (MSB), 60h (LSB).

Code:
ORG 00H

MOV R0, #0AH

MOV R1, #050h

MOV R2, #00H

MOV A, #00H

X:

ADD A,@R1

JNC Y

INC R2

Y:

INC R1

DJNZ R0, X

MOV 60H, R2

MOV 61H, A

END

Result:

Conclusion: We did the sum of array of 8 bit numbers and stored it in 60h and 61h.
12)

Question:
Move a block of memory from 30h-39h to 40-49h.

Code:
ORG 00H

MOV B, #0AH

MOV R1, #030h

MOV R0, #040H

X:

MOV A,@R1

MOV @R0, A

INC R0

INC R1

DJNZ B, X

END

Result:

Conclusion:
We moved the values from one addresses to other addresses with the help of this
algorithm.
13)

Question:
Move a block of memory from 30h-39h to 40-49h IN REVERSE
ORDER.

Code:
ORG 00H
MOV B, #0AH
MOV R1, #030h
MOV R0, #049H
X:
MOV A,@R1
MOV @R0, A
DEC R0
INC R1
DJNZ B, X
END
RESULT:

Conclusion:
We have moved the values from one address to another address in
reverse order.
14).

Question:
Move a block of 10 bytes of memory from the address (30h-39h) to
(35h-3Eh).

Code:
ORG 0H

MOV R0, #39H


MOV R1, #3EH
MOV R2, #0AH
X:
MOV B,@R0
MOV @R1, B
DEC R0
DEC R1
DJNZ R2, X

END

RESULT:

CONCLUSION:
To move the data from 30h-39h to 35h-3Eh, first move the data from 35h-39h to 3Ah-3Eh. For
that make a loop in which move the data from 35h to 3Ah and increment both value 5 times.
And then for remaining data make another loop i.e. 30h-3h to 35
15).

Question:
Find the sum of an array of 10 bytes (30h to 39h), and store the result in 51h (LSB), 50h
(MSB). If carry is there, does the multiplication operation between the final carry (MSB) and the
result of sum (LSB), STORE THE RESULT IN 55h (LSB), 54h (MSB).

Code:
ORG 00H

MOV R0, #0AH

MOV R1, #030h

MOV B, #00H

MOV A, #00H

X:

ADD A,@R1

JNC Y

INC B

Y:

INC R1

DJNZ R0, X

MOV 50H, B

MOV 51H, A

MUL AB

MOV 54H, B

MOV 55H, A

END

Conclusion:
Here we are using one loop to do the summation of the given numbers stored in the addresses
from 30h to 39h.
16)

Question:
Multiply 16 bit number with 8 bit number.

Code:
ORG 00H

MOV 30H, #0ABH

MOV 31H, #054H

MOV 41H, #089H

MOV A, 41H

MOV B, 31H

MUL AB

MOV 52H, A

MOV R0, B

MOV A, 41H

MOV B, 30H

MUL AB

ADD A, R0

MOV 51H, A

MOV 50H, B

END

Result:
Conclusion:
For multiplying 16 bit number with 8 bit number we first multiplied the first 8 bit and then add
the result in second eighth bit and then multiplied it with the second eighth bit.
17).

Question:
Find the factorial of a number less than value 5h.

Code:
ORG 00H

MOV R0, #05H

MOV A, #01H

X:

MOV B, R0

MUL AB

DJNZ R0, X

END

Result:

Conclusion:
For finding the factorial of a given number we are using one single loop to multiply
iteratively.
18).

QUESTION
Find the square of 16 bit number.

CODE
ORG 0H

MOV R0, #0AFH

MOV R1, #0FFH

MOV A, R1

MOV B, R1

MUL AB

MOV 47H, A

MOV R3, B

MOV A, R0

MOV B, R1

MUL AB

ADD A, R3

MOV 46H, A

JNC X

INC B

X:

MOV 45H, B

MOV A, R1

MOV B, R0

MUL AB

MOV 57H, A

MOV R3, B
MOV A, R0

MOV B, R0

MUL AB

ADD A, R3

MOV 56H, A

JNC Y

INC B

Y: MOV 55H, B

MOV A, 57H

ADD A, 46H

MOV 28H, A

MOV A, 56H

ADDC A, 45H

MOV 27H, A

MOV A, 55H

ADDC A, #00H

MOV 26H, A

MOV 29H, 47H

END

RESULT

CONCLUSION

In this program, square of 16 bit is done as multiply two same numbers.


19).

QUESTION
Find the basic logic gate operation (XOR, AND, OR, XNOR). Between the values stored in
address 40h and 41h.

CODE
ORG 0h

MOV R0, #092h

MOV R1, #0EFh

MOV A, R1

MOV B, R0

ANL A, B

MOV 40H, A

MOV A, R1

MOV B, R0

ORL A, B

MOV 41H, A

MOV A, R1

MOV B, R0

XRL A, B

MOV 42H, A
CPL A

MOV 43H, A

END

RESULT

CONCLUSION
In this program, Logical operation like AND, OR & NOT are done using ANL, ORL & CPL
respectively

- In Logical OR operation, if same bit of both numbers are 0 then output of OR is 0


otherwise output will be 1.

For Logical XOR operation XRL instruction is used and for XNOR operation compliment
of XOR is the output.
20).

QUESTION
Compare two numbers, that has stored in address 30h and 31h.

If x>y, find the logic AND operation between x and y.

If x=y, find the logic OR operation between x and y.

If x<y, find the logic XNOR operation between x and y.

CODE
Org 00h

MOV 30H, #0AH

MOV 31H, #0BH

MOV A, 30H

MOV B, 31H

CJNE A, B, NOT_EQUAL

ORL A, B

MOV 35H, A

SJMP EXIT

NOT_EQUAL: JNC NEXT

XRL A, B

CPL A

MOV 35H, A

SJMP EXIT

NEXT:ANL A,B

MOV 35H,A
EXIT:

END

RESULT

CONCLUSION
In this question we aware able to figure out he comparison operations with the help of
CJNE command so when the source is less than or equal to destination the carry flag is
not activated and else it is activated.
21).

QUESTION
Store the 8 bit value in addresses 30h and 31h as nibble and find the sum of the
nibble.

CODE
org 00h

MOV 29H, #0ABH

MOV 31H, #010H

MOV A,29H

MOV B,31H

DIV AB

MOV 30H,A

MOV 31H,B

ADD A,B

END
RESULT

CONCLUSION
Here we are storing the two different nibbles in two different addresses and we are getting it
by dividing the number by #010H.
22).

Question
String of data is stored in XRAM starting from the address 0000H to 0009H, count the
number of zeroes and non-zero numbers and store the result in 000AH and 000BH respectively.

CODE
ORG 00H

MOV DPTR, #0000H

MOV R0, #00H

MOV R1, #00H

MOV R2, #0AH

TIME: MOVX A, @DPTR

JZ SOURCE

INC R0

INC DPTR

SJMP Z

SOURCE: INC R1

INC DPTR

SJMP Z

Z: DJNZ R2, TIME

MOV DPTR, #000AH

MOV A, R1
MOVX @DPTR, A

INC DPTR

MOV A, R0

MOVX @DPTR, A

END

RESULT

CONCLUSION
We have used the MOVX command as we are dealing with external memory. The program can
then be successfully completed by using JZ command
23).
Question

Generate and store the first 10 numbers of Fibonacci series starting


from internal memory 30H

CODE
ORG 00H

MOV R0, #30H

MOV R1, #31H

MOV R5, #08H

TIME: MOV A,@R0

INC R0

MOV B, A

MOV A,@R1

INC R1

ADD A, B

MOV @R1, A

DJNZ R5, TIME

END

RESULT
CODE
Each number in this case is a simple addition of the previous 2 numbers. This can
be done with the use of an appropriate counter value and INC command
24).
Question

String of data is stored in XRAM starting from the address 000H to 0009H,
find the greatest number and store it in address 000AH

CODE
ORG 00H
MOV R2, #0AH
MOV 40H, #00H
MOV DPTR, #0000H
DO:
MOVX A,@DPTR
MOV 30H, A
INC DPTR
MOV A, 40H
CJNE A, 30H, X
SJMP Y
X:
JNC Z
XCH A, 30H
MOV 40H, A
Z:
NOP
Y:
NOP
DJNZ R0, DO
MOV DPTR, #000AH
MOV A, 40H
MOVX @DPTR, A
END

RESULT

CODE
We have successful compared a string of numbers and stored the final output in a
given memory location by the use of CJNE and XCH command.
25).
Question

String of data is stored in XRAM starting from the address 000H to 0009H, find the least number and
store it in address 000BH

CODE
ORG 00H

MOV R0, #0AH

MOV 40H, #0FFH

MOV DPTR, #0000H

DO:

MOVX A,@DPTR

MOV 30H, A

INC DPTR

MOV A, 40H

CJNE A, 30H, X

SJMP Y

X:

JC Z

XCH A, 30H

MOV 40H, A

Z:

NOP

Y:

NOP

DJNZ R0, DO

MOV DPTR, #000AH


MOV A, 40H

MOVX @DPTR, A

END

RESULT

CODE
We follow the same commands used in the previous
26).
Question

Generate a square wave of 500 Hz using timer 0(mode 1) at port 1.0

CODE
ORG 00H

MOV TMOD, #01H

AGAIN: MOV TL0, #0FCH

MOV TH0, #0F3H

SETB TR0

TIME: JNB TF0, TIME

CPL P1.1

CLR TR0

CLR TF0

SJMP AGAIN

RESULT

CODE
We learn about the basics of TMOD register and how to generate a square wave using Timer 0
Mod-1, which is used in 16 bit.
27).
Question

Generate a square wave of 1 kHz using timer 1(mode 1) at port 1.4

CODE
ORG 00H

MOV TMOD, #10H

AGAIN: MOV TL1, #0FEH

MOV TH1, #0F9H

SETB TR1

TIME: JNB TF1, TIME

CPL P1.4

CLR TR1

CLR TF1

SJMP AGAIN

RESULT

CODE
Here, instead of timer 0, we have used timer 1 which changes the value of TMOD register
28).
Question

Generate a square wave of 100 Hz using timer 0(mode 1) at port 1.0 while pressing the switch at port
2.0

CODE
ORG 00H

MOV TMOD, #01H

AGAIN: MOV TL0, #0E7H

MOV TH0, #0C3H

Z: JNB P2.0, Z

SETB TR0

TIME: JNB TF0, TIME

CPL P1.0

CLR TR0

CLR TF0

SJMP AGAIN

END

RESULT
CONCLUSION
We have learnt how to generate a square wave which is generate only when a specific switch is selected
and remains 0 which it is not selected.
29).
Question

Generate a square wave of 200 Hz using timer 1(mode 1) at port 1.3 while pressing the switch at port
2.3

CODE
ORG 00H

MOV TMOD, #10H

AGAIN: MOV TL1, #0F3H

MOV TH1, #0E1H

Z: JNB P2.3, Z

SETB TR1

TIME: JNB TF1, TIME

CPL P1.3

CLR TR1

CLR TF1

SJMP AGAIN

END

RESULT
CONCLUSION
It is the same as the previous question, only difference being we have used timer 1 instead of timer 0,
which changes the value of TMOD register
30).

QUESTION

Generate a square wake of 10 kHz using timer 1 by auto reload mode (mode 2) in port 1.3, while
pressing switch at port 2.4

CODE

ORG 00H

MOV TMOD, #20H

MOV TH1, #66H

AGAIN:

Z: JNB P2.4, Z

SETB TR1

TIME: JNB TF1, TIME

CPL P1.3

CLR TR1

CLR TF1

SJMP AGAIN

END
RESULT

CODE
We have learnt about Mod-2 operation of the timer, also known as Auto reload mode. This is used as 8
bit mod.
31).
Question

Generate a PWM of 1 kHz, that has duty cycle of 70 percentage using timer 0 (mode 1) in port 1.0, while
pressing switch at port 2.0

CODE
ORG 00H

MOV TMOD, #01H

MOV P2, #00H

MOV P1, #00H

X: MOV TL0, #065H

MOV TH0, #0FCH

Z: JNB P2.0, Z

ACALL DELAY

CPL P1.0

MOV TH0, #0F7H

MOV TL0, #096H

ACALL DELAY

CPL P1.0

SJMP X

DELAY: SETB TR0

TIME: JNB TF0, TIME

CLR TR0

CLR TF0

RET
END

RESULT

CONSLUSION
We have learnt how to generate a square wave where the on and off percentage is not 50% each. This
can be done by using different count values in TH0 and TL0.
32).
Question

Generate a PWM of 2 kHz, that has duty cycle of 10 percentage using timer 1 (mode 1) in port 1.5, while
pressing switch at port 2.3

CODE
ORG 00H

MOV TMOD, #10H

MOV P2, #00H

MOV P1, #00H

X: MOV TL1, #097H

MOV TH1, #0FAH

Z: JNB P2.3, Z

ACALL DELAY

CPL P1.5

MOV TH1, #0FFH

MOV TL1, #066H

ACALL DELAY

CPL P1.5

SJMP X

DELAY: SETB TR1

TIME: JNB TF1, TIME

CLR TR1

CLR TF1

RET
END

RESULT

CONSLUSION
Here, we have used timer 1 to generate a PWM instead of timer 0 which changes the value of TMOD
register.
33).
Question

Generate a square wave of 1 kHz, using timer 0 mode 1 interrupt in P1.1, while pressing switch
a P2.1.

CODE
ORG 0000H

LJMP MAIN

ORG 000BH

CPL P1.1

MOV TH0, #0FAH

MOV TL0, #00H

RETI

ORG 0030H

MAIN:

MOV A, #00H

MOV P2, A

X: JNB P2.1, X

MOV TMOD, #01H

MOV IE, #82H

BACK:

SETB TR0

SJMP BACK

END

RESULT
CODE
Here we have learnt how to use the timer in interrupt mode. When overflow is generated, program flow
is stopped and ISR is generated.
34).
Question

Switch is connected at P2.1, monitor the state of the switch and generate following wave of 50% duty
cycle at P1.1 using timer 1(mode 1) as mentioned

1. When P2.1=0, generate square wave of 5kHz


2. When P2.1=1, generate square wave of 2kHz

CODE
ORG 00H

JNB P2.1, MOVE

MAIN: MOV TMOD, #10H

MOV TH1, #0FCH

MOV TL1, #0FFH

SETB TR1

X: JNB TF1, X

CLR TR1

CLR TF1

CPL P1.1

JNB P2.1, MOVE

JB P2.1, MAIN

MOVE: MOV TMOD, #10H

MOV TH1, #0FEH

MOV TL1, #0CCH

SETB TR1

HELL: JNB TF1, HELL

CLR TR1

CLR TF1
CPL P1.1

JNB P2.1, MOVE

JB P2.1, MAIN

END

RESULT

CONCLUSION
Here, we have to check the status of the switch (port P2.1) after every cycle. Hence we have to
prepare separate subroutines for the corresponding time delay.
35).
Question

Repeat question 33 using timer 1(mode 1) in interrupt mode

CODE
ORG 0000H

LJMP MAIN

ORG 001BH

CPL P1.1

MOV TH1, #0FAH

MOV TL1, #00H

RETI

ORG 0030H

MAIN:

MOV A, #00H

MOV P2, A

X: JNB P2.1, X

MOV TMOD, #10H

MOV IE, #88H

BACK:

SETB TR1

SJMP BACK

END

RESULT
CONCLUSION
When overflow is generated program flow is stopped and ISR is generated.
36).
Question

Repeat question 34 using timer 0(mode 1) under following conditions

1. When P2.1=0, generate square wave of 5kHz 20% duty cycle


2. When P2.1=1, generate square wave of 2kHz 70% duty cycle

CODE
ORG 0000H

BACK:

JB P2.1, X

LCALL FIVE

SJMP Y

X:

LCALL ONE

Y:

SJMP BACK

ONE:

: ON

MOV TMOD, #01H

MOV TH0, #0F7H

MOV TL0, #9AH

SETB TR0

G: JNB TF0, G

CPL P1.1

CLR TF0

CLR TR0
; OFF

MOV TMOD, #01H

MOV TH0, #0FCH

MOV TL0, #66H

SETB TR0

H: JNB TF0, H

CPL P1.1

CLR TF0

CLR TR0

RET

FIVE:

; ON

MOV TMOD, #01H

MOV TH0, #0FFH

MOV TL0, #85H

SETB TR0

F: JNB TF0, F

CPL P1.1

CLR TF0

CLR TR0

; OFF

MOV TMOD, #01H

MOV TH0, #0FEH

MOV TL0, #15H

SETB TR0

J: JNB TF0, J

CPL P1.1
CLR TF0

CLR TR0

RET

END

RESULT
CONCLUSION
Here the duty cycle which is to be generated depends upon the position of the switch.
37).
Question

Generate a PWM signal of 10 kHz and duty cycle 70% at P1.1 using timer 0 interrupt in auto reload
mode.

CODE
ORG 0H

LJMP START

ORG 000BH

CLR TR0

CPL P1.1

RETI

ORG 0030H

START:

SETB P1.1

MOV IE, #82H

MOV TMOD, #02H

BACK:

MOV TH0, #29H

SETB TR0

MOV TH0, #0A4H

SETB TR0

LJMP BACK

END

RESULT
CONCLUSION
Here we have used mode 2 timer in interrupt mode.
38).
Question

Generate a PWM signal of 10 kHz and duty cycle 20% at P1.1 using timer 1 interrupt in auto reload mode.

CODE
ORG 0000H

MOV R0, #02H

MOV R1, #08H

LJMP START

ORG 001BH

JNB P1.1, OFF

DJNZ R0, X

CLR P1.1

MOV R0, #02H

SJMP X

OFF:

DJNZ R1, X

SETB P1.1

MOV R1, #08H

X:

RETI

ORG 0030H

START:

MOV TMOD, #20H

MOV IE, #88H

MOV TH1, #0E1H

SETB P1.1

SETB TR1
BACK: SJMP BACK

END

RESULT

CONCLUSION
This question is similar to the previous question, but timer 1 is used instead of timer 0.
39).
Question

Generate a PWM signal of 1 kHz and duty cycle 60% at P1.4 using timer 1 interrupt in mode-1(16 bit mode)

CODE
ORG 0000H

LJMP START

ORG 001BH

JNB P1.4, ON

MOV TH1, #0FBH

MOV TL1, #033H

SJMP X

ON:

MOV TH1, #0F8H

MOV TL1, #0CDH

X:

CPL P1.1

RETI

ORG 0030H

START:

MOV TMOD, #10H

MOV IE, #88H

MOV TH1, #0F8H

MOV TL1, #0CDH

SETB P1.4

SETB TR1
BACK: SJMP BACK

END

RESULT

CONCLUSION
Here, timer is used in mode -1 unlike the previous questions where it was operated in auto reload mode

0, #0FEH

MOV TL0, #0CD H

SETB TR0

X1: JNB TF0, X1

CLR TR0

CLR TF0

CPL P1.1

JNB P2.1, DELAY1

JB P2.1, DELAY2

END

Vous aimerez peut-être aussi