Introduction - If you have any usage issues, please Google them yourself
STM32 microcontroller, using digital Correlation Method for Measuring the phase difference between two waves, including engineering, tested by simulated data, you can use slightly modified, with a theoretical document.