Showing results for 
Search instead for 
Did you mean: 

Why does NUCLEO-144 H723ZG measure period time with almost 1Hz error?

Associate III

A 720mV RMS sine wave, biased to +1.25V is connected to the PB2 pin. PB2 is the COMP1 positive input. The COMP1 negative input is connected to the internal reference voltage (+1.22V) The output of the comparator is connected to PA0 which is the input capture channel 1 input of TIM2 (32-bit) timer. The TIM2 runs from 275MHz clock and it is started in input capture channel1 with interrupt mode. It works, but it measures 119.3Hz instead of 120Hz. 

I had to set the comparator mode to COMP_POWERMODE_MEDIUMSPEED because with the COMP_POWERMODE_HIGHSPEED I got bouncing signal (spikes, glitches) at the rising/falling edges of the comparator output. The max hysteresis is used.

The error is not large and consequent about 0.6 – 0.7Hz less: The standard deviation also large: 0.07Hz, is should be 0.002Hz.

Maybe the NUCLEO-114 runs from an RC oscillator, not crystal?

As far as I understand the CPU is clocked from HSE clock. It is MCO of STLINK-V3E which is 8MHz. Is this an RC oscillator or crystal? The other acceptable option would be the X3 25MHz crystal, but unfortunately it is not assembled...




Maybe you check again your core frequency by toggling a GPIO with the Systick interrupt, which is usually 1 ms (check your code).