An original algorithm combining both the pulse-echo method and the continuous-wave phase-shift method was developed for ultrasonic distance-measurement applications, in order to optimize the resources utilization of a microcontroller of general purpose tasks. The technique is based on a particular signal processing method which determines the approximate ToF by computing the cross correlation between the envelope of the transmitted and received signals and time-indexing of the peak of this function after a parabolic interpolation. The carrier phase shift between emission and reception is then computed in order to drastically refine the final result.