How to calculate phase difference between phase shifted sine waves in stm32?
I am using stm32-g07 and I managed to generate two waves: one reference and another phase shifted. Now I want to calculate the phase shift between the two. I tried two options:
- Try when the DAC channel output values for 1 and 2 get maximum and subtract the values. {this one gave me inaccurate result}
- instead of digital values between 0-4095, I converted them to voltage. {haven't tried this for two dacs yet}
However, in both cases, I don't get the index for the highest peak because I am using a phase accumulator and based on the phase increment, the peak value is constantly fluctuating. How to solve this problem?
The code is a bit mess because i was trying different methods. But my sine wave generation is here : void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
[Code in comment below]