MPMC Lab DA 4
MPMC Lab DA 4
Name: RAKSHITH S
Reg No: 22BEE0133
Slot: L11 + L12
Experiment no - 4(a), 4(b) and 3(b)
Exp - 4(a) Date: 10.09.2024
Exp - 4(b) Date: 24.09.2024
Exp - 4(c) Date: 01.10.2024
Experiment - 4(a)
Square wave Generation
Aim:
Generate a 50Hz square wave on P1.2 using timer-0 and mode-1.
Algorithm:
i. Set TMOD register.
ii. Set initial timer values.
iii. Use loop to restart the timer.
Code:
MOV TMOD, #10H
L1: MOV TL1, #000H
MOV TH1, #0DCH
SETB TR1
L: JNB TF1,L
CLR TR1
CLR TF1
CPL P1.2
SJMP L1
END
Output:
Signed document:
Result:
The square waveform has been generated successfully in Keil uVision.
Experiment - 4(b)
Interrupts
Aim:
To turn ON the LED if switch is pressed.
To turn OFF the same LED if the switch is not pressed.
Algorithm:
i. Use interrupt.
ii. When the switch is pressed the interrupt should execute and turn on a
LED.
Code:
I. Without interrupt
SETB P1.1
L: JB P1.1,Η
SETB P1.0
SJMP EXIT
H:CLR Pl.0
EXIT:
SJMP L
ORG 0
LJMP L
ORG 50H
L: MOV IE, #81H
MOV TCON, #1H
L1:CLR P1.0
SJMP L1
ORG 3
setb Pl.0
clr IT0
RETI
Output:
Signed document:
Result:
The given task of switching on of a LED while pressing a switch is
successfully completed.
Experiment - 4(c)
7-segment display
Aim:
To display our registration number on the 7 segment display continuously.
Algorithm:
i. Convert registration number into its respective hex format.
ii. Move the hex numbers to registers.
iii. Using delay function change the letters or numbers.
iv. Give the obtained hex code as input.
Code:
mov 20H, #5BH
mov 21H,#5BH
mov 22H,#7CH
mov 23H, #79H
mov 24H,#79H
mov 25H,#3FH
mov 26H,#06H
mov 27H,#4FH
mov 28H,#4FH
L1: MOV R7,#09H
mov R0,#20H
L: MOV A, @RO
MOV P1,A
ACALL DELAY
INC RO
DJNZ R7,L
SJMP L1
DELAY:
MOV R2,#0FFH
L3:MOV R3,#0FFH
L2:DJNZ R3,L2
DJNZ R2,L3
RET
Output:
Signed document:
Result:
Registration number has been displayed on 7 segment display continuously.