HC-SR04 with STM32 gives unexpected values
I found out the HAL_getTick returns milliseconds, and the echos are less than 1 ms (sometimes).

However, I changed it just by counting the loop iterations and I get much better values:

Name : raw_values
    Details:{118, 233, 797, 971, 268, 15, 290, 854, 455, 62, 258, 525, 867, 865, 866, 581, 576, 576, 587, 588, 581, 0 &lt;repeats 1003 times&gt;}


The last 8 values (except the 0) I got when I placed a box steadily in front of the sensor.

I think if I calculate the exact duration (in ms) of one loop it should be ok and I forget about the bad resolution of the HAL ticks. Or I should use some hardware timer that I start and check.