Frequency measurement with STM32
I would use a zero-crossing detector circuit (google - tons of them, very easy) and then (depending on the frequency you're trying to measure) either use an input-capture timer/counter to automate the counting, simply reading &amp; resetting the count at given measurement intervals (much lower CPU load), or  use the input pulses to gate a fast counter (to count a LOW frequency) and calculate the inverse (for low frequencies it's easier to measure the time taken per pulse rather than pulses accumulated per time period).

Either should leave your CPU with very little hard work to do.