Microcontroller › 8051 › how to start timer by software and stop by external hardware and then taking resultant value of time? › plz tell me that is this
plz tell me that is this program is correct or it needs some more addition or correction. all the details are written in front of every command after “;” sign
ORG 0013H ; INT1 ISR
clr TR0 ;stops timer 0(pin p3.3 will be connected with ECHO OUTPUT PULSE PIN of SRF04)
mov DPL,TL0 ;save the TL0 values to lower DPTR portion
mov DPH,TH0 ;save the TH0 values to upper DPTR portion
LJMP RANGE_CHECKER ;from here the DPTR value will be shifted to furhter part of this remaining programe
RANGE_CHECKER:
{{{{{{here i will write further program}}}}}}
ORG 0030H
MAIN:
setb tcon.3 ; make INT1 edge triggerd(high-to-low) interrupt
setb tcon.1 ;make INT0 edge triggerd(high-to-low) interrupt
mov Ie,#10000101b ;enable external INT0,ITN1
mov tmod,#10011001b ;make timr to strt/stop by EXTRNAL HARDWARE,MODE 1,16 bit timers
mov tl0,#0000 ;load initial values in timer TLO
mov th0,#0000 ;load initial values in timer THO
setb p1.0 ;make pin P1.0 HIGH
call delay ;this delay will HIGH pin P1.0 for 10 usec
delay:
l1:mov r0,#1
djnz r0,l1
nop
nop
clr p1.0
end