当前位置:网站首页>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
边栏推荐
- 直接插入排序
- 虫子 STM32 中断 (懂的都懂)
- 选择排序法
- 顺序表查找
- [tcapulusdb knowledge base] [list table] example code for replacing the data at the specified location in the list
- How to process large volume xlsx/csv/txt files?
- 电商如何借助小程序发力
- MySQL optimization, the SQL execution is very stuck, and the SQL structure will not be changed until it ends in 10 seconds
- redis 精讲系列介绍八 - 淘汰策略
- How can I realize video call and interactive live broadcast in a small program?
猜你喜欢

Review the SQL row column conversion, and the performance has been improved

基于FPGA的VGA协议实现

直接插入排序

mysql常用指令
![[two points] leetcode1011 Capacity To Ship Packages Within D Days](/img/fd/c6f31a44ebaf41bd5ab2a342f10d06.png)
[two points] leetcode1011 Capacity To Ship Packages Within D Days
![[greed] leetcode991 Broken Calculator](/img/6e/ce552b55899c6e8d3c37f524f99f82.png)
[greed] leetcode991 Broken Calculator

Pytorch---Pytorch进行自定义Dataset

mysql如何删除表的一行数据

Using jhipster to build microservice architecture

redis 精讲系列介绍八 - 淘汰策略
随机推荐
【曾书格激光SLAM笔记】Gmapping基于滤波器的SLAM
怎样能在小程序中实现视频通话及互动直播功能?
redisTemplate和cacheManager操作redis有什么不同
MySQL common instructions
顺序表查找
【LeetCode】179. Maximum number
QMainWindow
Tencent cloud tcapulusdb helps tmeland, the first virtual Music Carnival in China, and tens of thousands of people cross the new year together!
关于sql语句的问题
华为联机对战服务玩家快速匹配后,不同玩家收到的同一房间内玩家列表不同
Tcapulusdb Jun · industry news collection (III)
【LeetCode】23. 合并K个升序链表
2022年的软件开发:首席信息官应该知道的五个现实
SVG+JS智能家居监控网格布局
【LeetCode】翻转链表II
IDEA-导入模块
【LeetCode】179. 最大数
Flutter怎么实现不同缩放动画效果
怎么使用Shell脚本实现监测文件变化
8 key indicators to measure technology debt in 2022




























