Stm32 external clock Source mode 2 and external clock source mode 1 can be used to achieve the count function, what is their difference?
The above 2 modes correspond to different PIN inputs:
External clock source Mode 2 <-->TIMX_ETR
External clock source mode 1 <-->timx_chx
From the functional block diagram can be seen, ETR mode more than a divider ETPs, search for the divider register, as explained below: The external trigger signal ETRP frequency must be at most timxclk frequency of 1/4. When you enter a faster external clock, you can use the prescaler to reduce the frequency of the ETRP .
Each timer can only count one signal at a time, but each timer can capture a 4-way signal simultaneously.
If you need to sample the pulse width and frequency of the multiplex signal, capture mode is used.
The ETR filter is selected by configuring the TIMX_SMCR etf[3:0] bit, and these 4 bits can be selected by the following filtering methods:
0000: No filtering, sampling with Fdts
0001: Sampling frequency is fck_int, n=2.
0010: Sampling frequency is fck_int, n=4.
0011: Sampling frequency is fck_int, n=8.
0100: Sampling frequency is FDTS/2, n=6.
0101: Sampling frequency is FDTS/2, n=8.
....... The above FDTS is configured by CKD in TIMX_CR1:
00:tdts = Tck_int
01:tdts = 2xtck_int
10:tdts = 4xtck_int
11: Reserved
Suppose etf=0101, i.e. "sampling frequency is FDTS/2, n=8"; ckd=01 is selected, i.e. "Tdts = 2xtck_int" and assumes Fck_int=72mhz.
At this point, it can be calculated that the sampling frequency is 72mhz/2/2=18mhz, because n=8, that is, the filter can filter out the input of less than 444.4ns pulse.
According to this principle, it is my understanding that the filter is placed behind the frequency divider to ensure that the passed signal is not more than a certain limit, not to filter out narrow pulses. However, if a high frequency narrow pulse appears on the ETR, for example, when the divide factor is 4 o'clock, if a narrow pulse of more than 9MHz appears on the ETR, it will be filtered out after the crossover and filter. , "Filter on the back can be more guaranteed to get clean waveform", can follow the above analysis to understand
Stm32 Timer Count function