In addition, after the end of HHH subroutine, there is no jump instruction or wait instruction, leaving the program nowhere to run.
The idea of feeling good seems a little too hard.
My suggestion is:
Set the timer for a long time after starting, and don't start it first.
Suppose we set the timer time to 125ms, and then in the program of timer interruption, first restore TH, and then set a register plus 1 program in it, which will be used later.
Immediately after sending the ultrasonic wave, start the timer,
After startup, double-check whether the P 1.6 port is received. When it is received, close the timer and read the TH value of the timer and the value of the register in the interrupt. Based on these two values, can't we work out a more accurate time?
And it's one-off, so you don't need to test every distance.