Reputation: 5873
I have F401RB nucleo board Timer4 configured with these values
The PWM output varies considerably , frequency between 40kHz and 41.67 kHz and the duty Cycle between 50% and 52%. Is there a way to achieve better stablity
With due respect to Sealese logic, is it the LA that lags in capturing real output ?
Upvotes: 0
Views: 3234
Reputation: 9587
You are attempting to read a 40 KHz signal at a 1 MHz sampling rate, in other words there are only 25 samples per cycle of your signal. If there is a +/-1 error in reading a particular cycle (and there will always be a possibility of such an error, due to the complete lack of synchronization between the signal and the sampling), the displayed frequency will be off by a factor of 1/25 - either 38461 Hz or 41667 Hz.
If you wanted to determine the exact frequency to within 1% (for example), you'd need a sampling rate 100 times greater than the signal frequency.
Upvotes: 7