SLAA638A august 2014 – may 2023 MSP430I2040 , MSP430I2041
For frequency measurement, the integer number of samples per cycles is taken and filtered over many cycles to produce a mains period value with high resolution. However, this can take quite a long time to settle. To improve the settling time, a straight line interpolation between the voltage samples each side of a zero crossing is taken. To make this more robust in the presence of spike on the supply rail, unreasonable values from the estimation is ignored. Figure 2-7 illustrates this behavior.
Since noise spikes can cause errors, a rate of change check is used to filter out the possible erroneous signals and so to make sure that the two points are interpolating from are genuine zero crossing points. (For example, if there are two negative samples, a noise spike can make one of them positive and, therefore, making the negative and positive pair looks as if there is a zero crossing).
The resultant cycle to cycle timing goes through a weak low pass filter to further smooth out cycle to cycle variations. The result is a stable and accurate frequency measurement result that is tolerant of noise.