Thank you for your message.
Modifying the interrupt period, this is what I get:
5 us -> h = 18
10 us -> h = 17
30 us -> h = 16
This is what I can see on the oscilloscope:
Excitation pulse: square wave, 3.4 V, about 20 us wide (strange considering having it high for 1 us in code...)
Echo pulse: square wave, 3.4 V, 0.5 ms
A return echo of 0.5 ms (500 us), corresponds to a range of 8.5 cm aprox, which is the real distance to target.
The ping datasheet specifies a longer excitation pulse, though it works fine as it is. It seems that the important thing is to leave room for the echo.
I am not using an external crystal, only the internal one.
Still cannot get a reasonable number in the counter h....