Microcontroller › 8051 › how to start timer in 89C51 by programing and stop by external hardware
- This topic has 2 replies, 2 voices, and was last updated 13 years, 4 months ago by ZOBI.
-
AuthorPosts
-
July 12, 2011 at 11:19 am #1130ZOBIParticipant
i want to start a timer in 89c51 after a 10 usec pulse is given by pin p1.1 then timer wil continue to count the time and stop when it gets low on pin p1.2 , basicaly pin p1.2 is initialy LOW i want to stop the timer when it goes from low to HIGH and then again low after that i want to stop the timer and also i want to use that TIMER value for further process
plz can any buddy help me out for the source code of that
thanks in advance
July 13, 2011 at 1:12 am #6450romel emperadoParticipantthere are many projects here using timers… go and search for that and also read this
July 21, 2011 at 8:14 pm #6488ZOBIParticipantbasically i want this in my program
i want to use 16 bit timer then these steps in my prog.
1. pin p1.0 gives high for 10 microsecond then goes LOw, on its falling edge Timer 0 starts to count UP(with the help of INT0 timer start)
2. Then Timer will be stopped when pin P1.1 goes from high-to-LOW means on its falling edge(with the help of INT1 timer stop)
3. Then the TIMER value at which timer is stop ,will be save on Accumulator “A” or any register
4. then i will use that value for to compare between a range of diffrent values , the prog. will check whether the value is in between
166 microsecond to 1660 microsecond volt 1
1661 microsecond to 3320 microsecond volt 2
3321 microsecond to 4980 microsecond volt 3
4981 microsecond to 6640 microsecond volt 4
.
.
.
.
.
.
.
.
5. Then after a series of comparing/checking TIMEr value from these RANGES ,when TIMEr value comes in these any of range microcontroller will send a CODE to DAC0808 to produce a voltage of respective code like on volt 1 it will send a code to DAC0808 to produce more voltage and on sending a code of volt 2 it will send a code to DAC0808 to produce less voltage as copmared to volt and and so on..
basically i m designing a project Using ultrasonic range finder SRF04,89C51 ,DAC0808
when any object will come in front of sensor it will reflect back a the ultrasound waves which wass emited by sensor on reciving that a pin goes from high to LOw after that controller will calculate the time how much time does the wave has taken in air then it will give code to DAC0808 to produce voltages which will vibrate a motor according to the distance
here is the code which I have made to which makes pin p1.0 high for 10 usec ,start stop the timer 0 and then the VALUE of timer TL0 & TH0 will be added and will be saved in “A” but I don’t know is this correct or not.plz chek it
org 0000h
ljmp main
ORG 0003H
setb tr0
ORG 0013H
clr a
mov r4,tl0
mov a,th0
add a,r4
ORG 0030H
MAIN:
setb tcon.3
setb tcon.1
mov Ie,#10000101b
mov tmod,#10011001b
mov tl0,#0000
mov th0,#0000
setb p1.0
call delay
delay:
l1:mov r0,#1
djnz r0,l1
nop
nop
clr p1.0
end
-
AuthorPosts
- You must be logged in to reply to this topic.