Microcontroller › 8051 › how to start timer by software and stop by external hardware and then taking resultant value of time? › i m makeing a project for
i m makeing a project for blind person navigation
When any obstacle come in front of Ultrasonic range finder SRF04 ,they sends signal to 89C51 controller n controller vibrates the vibration motors attached to any particular area where the circuit is attached so a blind can understand that he or she is close to any obstacle , n the closer the obstacle the more vibration produce, means vibration should be inversely proportional to distance between person and obstacle,
i hav made major part of the programing of this project but still want help from u people to tell me is this source code have some mistakes or not
org 0000h
ljmp main
ORG 0003H ; INT0 ISR
setb TR0 ; starts timer 0 (pin p3.2 will be connected with the pin which is giving 10 usec pulse)
ORG 0013H ; INT1 ISR
clr TRO ;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
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 delaywill HIGH pin P1.0 for 10 usec
delay:
l1:mov r0,#1
djnz r0,l1
nop
nop
clr p1.0
end