Essay

665 Words 3 Pages
Lab # 9

Task # 1

OBJECT

Write a program for generating a pulse which has a low portion for 10ms and a high portion for 5ms.Use timer 0 in mode 1 for generating delay.

PROGRAM COMMENTS

org 00h ; originate the code from memory location 00h

main: ;main label

here: setb p1.1 ;here label, making p1.1 high

acall delay ;calling delay subroutine

clr p1.1 ;making p1.1 low

acall delay ;calling delay subroutine

acall delay ;calling delay subroutine

sjmp here ;unconditional jump tohere label

delay: ;delay subroutine

mov TMOD,#01h ;Selecting timer 0 mode 1

mov Th0,#0eeh ;Th0 = EEH

mov Tl0,#00h ;Tlo = 00h

setb tr0 ;Starting timer 0

h1:jnb Tf0,h1 ;jump to label
…show more content…
PROGRAM COMMENTS

org 00h ; originate the code from memory location 00h

here1: ;here1 label

setb p1.3 ;making p1.3 high

acall delay ;calling delay subroutine

acall delay calling delay subroutine

acall delay ;calling delay subroutine

clr p1.3 ;making p1.3 low

acall delay ;calling delay subroutine

sjmp here1 ;unconditional jump to here1 label

delay: ;delay subroutine

mov tmod,#20h ; Selecting timer 1 mode 2

mov th1,#8dh ;Th0 = 1AH

mov r0,#10 ;Moving value of 10 in R0

here2:mov r1,#200 ;Moving value of 200 in R0

here:setb tr1 ;Starting timer 1

back:jnb tf1,back ;jump to label back until Tf0 becomes high, back label

clr tr1 ;Stopping timer 0

clr tf1 ;clearing TF0 flag

djnz r1,here ;decrement in R0 and jump to here label until R1=0

djnz r0,here2 ;decrement in R0 and jump to here label until R0=0

ret ; return back to normal routine

end ;end directive, to end program

DELAY CALCULATION

FFh – 8Dh+1=73h

73h=115

115 x (1.085x10^(-6))= 1.24775x10^(-4)

Related Documents