Task 3
Task 3
Task 3
TASK 3
ASSESSMENT 3
Code:
ORG 0000H
MOV TMOD, #01H ; Timer 0 Mode 1
HERE:MOV TL0,#66H
MOV TH0,#0FCH
CPL P1.0
ACALL DELAY
SJMP HERE
DELAY: SETB TR0
AGAIN:JNB TF0,AGAIN
CLR TR0
CLR TF0
RET
END
Calculations:
Given,
∴ (64614.342)10 = (FC66)16
EXECUTION :
Implementation:
7. Use CLR TR0, CLR TF0 command to stop the timer and to clear the timer
flag 0 respectively.
8. Use RET command to return to the command just after ACALL DELAY.
Code:
ORG 0000H
MOV TMOD, #10H; Timer 1 Mode 0
HERE:MOV TL1,#33H
MOV TH1,#0FEH
CPL P1.0
ACALL DELAY
SJMP HERE
DELAY: SETB TR1
AGAIN:JNB TF1,AGAIN
CLR TR1
CLR TF1
RET
END
Calculations:
Given,
Frequency, f = 1000 Hz
EXECUTION :
Implementation:
6. Under DELAY function, use SETB TR1 command to start the timer, after the
timer starts the value of timer is incremented by 1. Use JNB TF1 command to
check the value of TF1; and jump out of the loop when TF1 will turn 1. TF1
will turn 1 when the timer reaches maxixum value (FFFF).
7. Use CLR TR1, CLR TF1 command to stop the timer and to clear the timer
flag 0 respectively.
8. Use RET command to return to the command just after ACALL DELAY.
Code:
ORG 0000H
MOV TMOD, #20H ; Timer 1 Mode 2 HERE:
MOV TH1,#76H
CPL P1.0
ACALL DELAY
SJMP HERE
DELAY: SETB TR1
AGAIN:JNB TF1,AGAIN
CLR TR1
CLR TF1
RET
END
3/09/18
Calculations:
Given,
Frequency, f = 3000 Hz
∴ 76 will be loaded in TH1 and no value will be loaded in TL1 as it is Auto Reload
Mode.
Execution:
3/09/18
Implementation:
Code:
ORG 0000H
MOV TMOD,#01H ; TIMER 0 MODE 1
MOV TL0,#000H
MOV TH0,#0DCH
SETB P1.0 ACALL
DELAY HERE:
MOV TL0,#00H
MOV TH0,#0DCH
CPL P1.0
ACALL DELAY
MOV TL0,#00H
MOV TH0,#0DCH
CPL P2.0
ACALL DELAY
11/09/18
SJMP HERE
DELAY: SETB TR0
AGAIN:JNB TF0,AGAIN
CLR TR0
CLR TF0
RET
END
Calculations:
∴ (56320)10 = (DC00)16
∴ 0DCH will be loaded in THO and 00H will be loaded in TL0
11/09/18
EXECUTION:
Implementation:
11.SJMP HERE command will be executed. Use HERE label after the command
used to give the initial delay of 10 mS to give the continuous output waveform.
12.Under DELAY function, use SETB TR0 command to start the timer, after the
timer starts the value of timer is incremented by 1. Use JNB TF0 command to
check the value of TF0; and jump out of the loop when TF0 will turn 1. TF0
will turn 1 when the timer reaches maxixum value (FFFF).
13.Use CLR TR0, CLR TF0 command to stop the timer and to clear the timer
flag 0 respectively.
14.Use RET command to return to the command just after ACALL DELAY.
Program 5: Write an ALP using 8051 to check the status of two switches connected
to port P2.1 and P2.2. If any one of the switches is ON (logic 1) make the LED
connected to port 2.7 to toggle for 250 microseconds. Repeat this continuously.
Code:
ORG 0000H
SETB P2.1
SETB P2.2
CLR P2.6 XX:
MOV C,P2.1
ORL C,P2.2
MOV P2.6,C
JNB P2.6,XX
MOV TMOD,#01H
MOV TL0,#1AH
MOV TH0,#0FFH
SETB P2.7
ACALL DELAY
MOV TMOD,#01H
MOV TL0,#1AH
MOV TH0,#0FFH
CLR P2.7
ACALL DELAY
SJMP XX
DELAY: SETB TR0
AGAIN:JNB TF0,AGAIN
CLR TR0
CLR TF0
RET
END
Calculations:
∴ (65306)10 = (FF1A)16
∴ 0FFH will be loaded in THO and 1AH will be loaded in TL0
Execution:
1. Declare the ports P2.1 & P2.2 as input ports using SETB.
2. Declare the port P2.6 as output ports using CLR.
3. Use ORL command to get the ORL gate output and store the result in port
P2.6.
4. Use JNB P2.6 command to check the value of port P2.6; and jump out of the
loop when port P2.6 will turn 1. If value of port P2.6 will be 0, move to label
XX . Use XX label before the commands used to get the OR gate result.
5. Write the TMOD value according to Timer 0 and Mode 1 configurations as
MOV TMOD,#01H.
6. Calculate the values to be loaded in TH (0FFH) and TL (1AH) according to
given time period of 250µs, set those values using MOV TL0,#1AH & MOV
THO,#0FFH.
7. Use SETB P2.7 command to set the value of port P2.7 = 1.
8. Use ACALL DELAY command to call the DELAY fuction.
9. Again write MOV TL#1AH & MOV THO,#0FFH.
10.Use CLR P2.7 command to set the value of port P2.7 = 0.
11.Use ACALL DELAY command to call the DELAY fuction.
12.SJMP XX command will be executed. Use XX label before the commands
used to get the OR gate result.
13.Under DELAY function, use SETB TR0 command to start the timer, after
the timer starts the value of timer is incremented by 1. Use JNB TF0
command to check the value of TF0; and jump out of the loop when TF0 will
turn 1. TF0 will turn 1 when the timer reaches maxixum value (FFFF).
14.Use CLR TR0, CLR TF0 command to stop the timer and to clear the timer
flag 0 respectively.
15.Use RET command to return to the command just after ACALL DELAY.