There are roughly two methods to measure the fundamental frequency:
1, high-speed sampling SPWM signal, Fourier transform, you can get the fundamental frequency.
2. Use low-pass filter to filter out high-order harmonics, leaving fundamental wave (sine wave or approximate sine wave), and then convert it into square wave pulse through shaping amplifier circuit, so it can be measured conveniently. The cutoff frequency of the low-pass filter can be selected near the fundamental frequency.