Assignment Test
Assignment Test
Explain how the square wave frequency is determined from the given 8051 assembly
program using Timer 1, and calculate the resulting frequency at pin P1.5 when the
XTAL is 11.0592 MHz and the timer is loaded with the value 7634H.
1. TIMER VALUES
Program
MOV TMOD, #10H ; Select Timer 1, Mode 1 (16-bit timer mode)
AGAIN: MOV TL1, #34H ; Load low byte of timer (TL1 = 0x34)
MOV TH1, #76H ; Load high byte of timer (TH1 = 0x76 → total =
0x7634)
SETB TR1 ; Start Timer 1
2. Explain how the 8051 microcontroller uses the INT1 external interrupt to control
an LED connected to pin P1.3 based on the falling edge of a pulse at P3.3.
PROGRAM:
ORG 0000H
LJMP MAIN
; ------------------------
; ISR for External Interrupt INT1 (P3.3)
; ------------------------
ORG 0013H
SETB P1.3 ; Turn ON LED at P1.3
MOV R3, #255 ; Load delay count
BACK: DJNZ R3, BACK ; Delay loop
CLR P1.3 ; Turn OFF LED
RETI ; Return from interrupt
; ------------------------
; Main Program
; ------------------------
ORG 0030H
MAIN: SETB TCON.2 ; Set INT1 as edge triggered (IT1 = 1)
MOV IE, #10000100B ; Enable INT1 (EX1) and global interrupt (EA)
HERE: SJMP HERE ; Stay in infinite loop