Wan Zulhelmi Wan Ahmad Kamar wrote: > Hi, I'm using a PIC18f252 with an ultrasonic transducer to receive > signal of 40kHz. The thing is that I want to calculate the time from > the moment the first data arrive until the second data arrive. How > can I do that? Basically, I need to know the time difference between > the arrival of those two data? I'll assume that the external circuit gives you two pulses, and you want to measure the delay between the two leading edges. The best way to to this is to use a CCP module in capture mode. This captures the value of a free running timer each pulse. Subtract the two values to get the delay time between pulses. ***************************************************************** Embed Inc, embedded system specialists in Littleton Massachusetts (978) 742-9014, http://www.embedinc.com _______________________________________________ http://www.piclist.com View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist