Microcontroller › 8051 › how to start timer in 89C51 by programing and stop by external hardware › basically i want this in my
basically 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