去看固件库的例程
STM32F10x StdPeriph Lib v3.5.0\Project\STM32F10x_StdPeriph_Examples\TIM\InputCapture
This example shows how to use the TIM peripheral to measure the frequency of an
external signal.
The TIMxCLK frequency is set to SystemCoreClock (Hz), the Prescaler is 0 so the
TIM3 counter clock is SystemCoreClock (Hz).
SystemCoreClock is set to 72 MHz for Low-density, Medium-density, High-density
and Connectivity line devices. For Low-Density Value line and Medium-Density
Value line devices, SystemCoreClock is set to 24 MHz.
TIM3 is configured in Input Capture Mode: the external signal is connected to
TIM3 Channel2 used as input pin.
To measure the frequency we use the TIM3 CC2 interrupt request,
so In the TIM3_IRQHandler routine, the frequency of the external signal is computed.
The "TIM3Freq" variable contains the external signal frequency:
TIM3Freq = TIM3 counter clock / Capture in Hz,
where the Capture is the difference between two consecutive TIM3 captures.
For Low-density, Medium-density, High-density and Connectivity line devices,
the minimum frequency value to measure is 1100 Hz.
For Low-Density Value line, Medium-Density and High-Density Value line devices,
the minimum frequency value to measure is 366 Hz.
@par Directory contents
- TIM/InputCapture/stm32f10x_conf.h Library Configuration file
- TIM/InputCapture/stm32f10x_it.c Interrupt handlers
- TIM/InputCapture/stm32f10x_it.h Interrupt handlers header file
- TIM/InputCapture/main.c Main program
- TIM/InputCapture/system_stm32f10x.c STM32F10x system source file
|