I'm tring to use the capture mode of the BF512 in order to find the frequency of an incoming PWM signal.
The PWM signal is connected to TIMER3 and the timer is set to WDTH_CAP mode and also to PULSE_HI and PERIOD_CNT=1.
If i understand correctly the TIMER3_PERIOD should be (Core clock/ PWM frequency) -number of clocks from rising edge to rising edge.
Meaning that if I want to find the frequency I can do (Core clock /TIMER3_PERIOD).
My problem is that although the PWM frequency is stable the TIMER3_PERIOD I'm getting is unstable and changes all the time.
Can anyone offer a code how to to solve this problem?