Contents
How does the input capture work in STM32?
As we’ve discussed in an earlier tutorial, the timer modules can operate a variety of modes one of which is the input capture mode. Where the timer gets clocked from an internal source and its current value is captured and saved to the input capture register whenever a special event occurs on the input capture channel pin.
How many channels does a STM32 timer have?
And also note that every single timer module has multiple (input capture/compare output) channels (3, 4, 6, or whatever found in the datasheet).
When to call the callback function in STM32?
The above callback function is called whenever the rising edge is detected. When called first time, Is_First_Captured was 0 so the hence the IC_Val1 will be recorded. When called in the second rising edge, the Is_First_Captured is 1 now so IC_Val2 will be recorded and you can see the rest.
How is input capture used in a microcontroller?
As the name implies, Input capture is used to capture the input signal given to the microcontroller and measures its frequency and pulse width. In this tutorial, I will only cover the frequency part and the pulse width will be covered in next one where we will use PWM Input to do that.
Is there a frequency meter on STM32F4?
I am trying to implement a frequency meter on STM32F4. Up to this point I have a working ADC converter with DMA and a timer which checks for the current voltage value and catches a zero crossing (with margin) and counts the counter. Now, what is the best way hot to determine the actual frequency?
How is the measured period calculated in STM32?
And the measured period is (T2-T1), so the frequency is calculated as (1/ (T2-T1)). And then, it’s printed to the serial port using UART1. Finally, the system state is flipped again to IDLE, and the whole process is repeated.
What’s the error percentage of STM32 frequency measurement?
The error (drift) in the frequency measurement is nearly 0.001% at the low end of the frequency spectrum. And it gets even better at high-frequencies the error percentage is even smaller at higher frequencies. There does exist a fundamental limitation for the upper and lower measurable frequencies using this technique.