Content originally posted in LPCWare by NXP_Europe on Tue Apr 17 23:45:35 MST 2012
Hi,
You are probably interested in the capture mode. Basically this mode lets you take a snapshot of the timer value on a external event (pin change).
You will need to have a digital input signal, signalling if there is, or if there is no ultrasound received. Let's assume a high signal if there is an ultrasound, and a low signal if there is none.
First you would inititalize the timer in capture mode to take the snapshot of the timer value on a rising edge of your "ultrasound present" signal and generate an interrupt on this event. More information on this can be found in the user manual, chapter 21. Then you can reset the timer value to 0, start the timer and enable the ultrasound transceiver. After this you will only have to wait for the capture interrupt and read the capture value.
Regards,