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.Accurate measurements (typically better than 1 mm, even for poorly reflecting targets for a distance of about 1 m) can be achieved despite low sample rate and limited computing capabilities. The algorithm is simple and needs no complex associated hardware. Moreover, the method can be easily adapted for other microcontrollers or digital signal processorbased platforms.