当前位置:网站首页>Bug STM32 advanced timer (haha, to tell you the truth, the hardware timer can't reflect its strength. In fact, I want to send the kernel timer. Just think about it. Take your time)
Bug STM32 advanced timer (haha, to tell you the truth, the hardware timer can't reflect its strength. In fact, I want to send the kernel timer. Just think about it. Take your time)
2022-06-23 04:17:00 【Hua Weiyun】
Advanced timer
Clock source
First, let's talk about the percentage of clock sources 99 Use the internal , other 3 Basically, I don't need it , The following three are for understanding , There is something wrong , A little confused
- Internal clock source CK_INT
- External clock mode 1— External GPIO Tix(x=1 2 3 4)
- External clock mode 2— External GPIO ETR
- Internal trigger input
Internal clock source
- The internal clock source comes from RCC Of TIMx_CLK
- TIMx_CLK So what is that equal to ? How to determine the ?
External clock mode 1
Clock signal input pin
- External GPIO TIx, Corresponding :TIMx_CH1/2/3/4
- TIM_CCMRx Bit CCxS[1:0] To configure , among CCMR1 control TI1/2, CCMR2 control TI3/4
filter
- If the frequency of external clock signal is too high or mixed with high frequency interference signal , We need to use filters to ETRP Signal resampling , To achieve the purpose of reducing frequency or removing high frequency interference
- from TIMx_CCMRx Bit ICxF[3:0] To configure
Edge detection
- The edge detection signal comes from the output of the filter , Before it becomes a trigger signal , Edge detection is needed , Decide whether the rising edge is valid or the falling edge is valid .
- from TIMx_CCER Bit CCxP and CCxNP To configure
Trigger selection
- When using external clock mode 1 when , There are two trigger sources , One is the filtered timer input 1( TI1FP1) And filtered timer input 2( TI2FP2)
- from TIMx_SMCR Bit TS[2:0] To configure
Enable counter
- Through the top 5 After one step , Finally, we just need to enable the counter to start counting , External clock mode 1 The configuration is complete .
- The enable counter consists of TIMx_CR1 Bit CEN To configure .
External clock mode 2
Clock signal input pin
When using external clock mode 2 When , The clock signal comes from a specific input channel of the timer TIMx_ETR, Only 1 individual .
External trigger polarity
- come from ETR The signal of pin input can be selected as rising edge or falling edge
- The specific reason is TIMx_SMCR Bit ETP To configure
External trigger prescaler
- because ETRP The frequency of the signal must not exceed TIMx_CLK( 180M) Of 1/4, When the frequency of the trigger signal is very high , You have to use a frequency divider to reduce the frequency
- The specific reason is TIMx_SMCR Bit ETPS[1:0] To configure
filter
- If ETRP The frequency of the signal is too high or mixed with high-frequency interference signals , A filter pair is required ETRP Signal resampling , To achieve the purpose of reducing frequency or removing high frequency interference
- The specific reason is TIMx_SMCR Bit ETF[3:0] To configure , Among them fDTS It's from the internal clock CK_INT Divide the frequency to get , The specific reason is TIMx_CR1 Bit CKD[1:0] To configure
From mode selection
- The filtered signal is connected to ETRF After pin , The trigger signal becomes the external clock mode 2 The input of , In the end, it's equal to CK_PSC, And then drive the counter CNT Count .
- Specific configuration TIMx_SMCR Bit ECE by 1 You can select the external clock mode 2
Enable counter
- Through the top 5 After one step , Finally, we just need to enable the counter to start counting , External clock mode 2 The configuration is complete
- The enable counter consists of TIMx_CR1 Bit CEN To configure .
Internal trigger input
- The internal trigger input is a prescaler that uses one timer as another . In terms of hardware, advanced control timer and general timer are internally connected , Timer synchronization or cascade can be realized .
- from TIMx_SMCR Bit TS[2:0] To configure
controller
- The controller is used to control , Sending commands
- CR1、CR2、SMCR、CCER, Mainly learn these registers .
Time base unit
Composition of time base unit
- 16 Bit prescaler PSC,PSC
- 16 Bit counter CNT, CNT
- 8 Bit repetition counter RCR,RCR( Advanced timer is unique )
- 16 Bit automatic reload register ARR,ARR
Input capture
Input channel
When using the signal to be measured from the external pin of the timer TIMx_CH1/2/3/4 Get into , Usually called TI1/2/3/4, In the later explanation of acquisition, we all use the following words for the signal to be measured TIx It's the standard name .
Input filtering and edge detection
Capture channels
Preassigned frequency counter
- ICx The output of the signal goes through a prescaler , Used to capture once when deciding how many events occur .
- Specifically, the register CCMRx Bit ICxPSC To configure , If you want to capture every edge of the signal , No frequency division .
Capture register
Output comparison
Output comparison register
Dead zone generator
Half bridge drive circuit with dead band insertion
Complementary output waveform with dead band insertion
Output control
Output pin
Input capture application
Measure pulse width and frequency
PWM The input mode
- The output comparison mode has a total of 8 Kind of , What is commonly used is PWM Pattern .
- By register CCMRx Bit OCxM[2:0] To configure .
Code
First we choose our feet , Here we use advanced timer
PWM Complementary output experiment , Dead time , With brake control
Complementary needs two feet , Deadband can be configured by software , The brake also needs a foot . We can only use advanced timers 1 了 , No, 8
边栏推荐
- Differences between MyISAM and InnoDB of MySQL storage engine
- 电商如何借助小程序发力
- Pyspark, paid for data cleaning and uploading to the database
- 虫子 日期类 下 太子语言
- MySQL data recovery (.Ibdata1, bin log)
- What is the digital "true" twin? At last someone made it clear!
- Weekly Postgres world news 2022w02
- 无线网络安全的12个优秀实践
- redisTemplate和cacheManager操作redis有什么不同
- The power of code refactoring: how to measure the success of refactoring
猜你喜欢
随机推荐
linux下的开源数据库是什么
线上MySQL的自增id用尽怎么办?
[leetcode] sum of two numbers II
Tcapulusdb Jun · industry news collection (III)
Tables de recherche statiques et tables de recherche statiques
redisTemplate和cacheManager操作redis有什么不同
x64dbg 基本使用技巧
高效的远程办公经验 | 社区征文
[从零开始学习FPGA编程-40]:进阶篇 - 设计-竞争与风险Risk或冒险
[machine learning] wuenda's machine learning assignment ex2 logistic regression matlab implementation
What is the potential of dmail based on Web3.0? First round financing of $10 million?
最新编程语言排行榜
Flutter怎么实现不同缩放动画效果
【owt】owt-client-native-p2p-e2e-test vs2017构建2 :测试单元构建及运行
January 17, 2022: word rule II. Give you a pattern and a character
Similar to RZ / SZ, trzsz supporting TMUX has released a new version
会话和守护进程
城链科技董事长肖金伟:践行数据经济系国家战略,引领数字时代新消费发展!
Not just offline caching- On how to make good use of serviceworker
2022年的软件开发:首席信息官应该知道的五个现实






































