TIM1_Int_Init(999,71)那么TIM1->CNT是多长时间
时间: 2023-06-19 15:07:27 浏览: 281
假设TIM1的时钟频率为f,则计数器CNT的最大值为ARR+1,其中ARR为自动重载寄存器的值,即TIM1_Int_Init函数中的第一个参数999。因此,每经过一个计数器CNT,计数器CNT的值会增加1,当CNT的值达到ARR+1时,计数器CNT会被自动重置为0并触发更新事件。
根据TIM1_Int_Init函数中的第二个参数71,可以计算出TIM1的时钟预分频系数为72,即f = TIMx_CLK / 72。因此,每经过一个计数器CNT,计数器CNT的值会增加1,所经过的时间为:
1/f = 72 / TIMx_CLK
因此,TIM1->CNT经过999+1个计数器CNT所经过的时间为:
(999+1) * 1/f = (999+1) * TIMx_CLK / 72
需要知道TIMx_CLK的具体值才能计算出具体的时间。
相关问题
TIM1_Int_Init(999,71),那么TIM1->CNT是多长时间,TIM_TimeBaseStructure.TIM_ClockDivision = 0;
根据你提供的代码,TIM1的时钟源为APB2,假设APB2的时钟频率为72MHz,那么TIM1的计数频率为72MHz/(999+1)=72kHz。因此,每计数一次所需要的时间为1/72kHz约等于13.89us。
关于`TIM_TimeBaseStructure.TIM_ClockDivision = 0;`,它表示时钟分频系数为不分频,也就是不对时钟源进行分频。因为这里的时钟源即为APB2时钟,而APB2时钟的分频系数默认为1,因此这里设置为0和不设置效果是一样的。
TIM1_Int_Init(999,71),TIM_TimeBaseStructure.TIM_ClockDivision = 0;那么TIM1->CNT是多长时间
TIM1的计数器CNT的时间取决于TIM1的时钟频率和计数器的位数。在这个例子中,TIM1的时钟频率是72MHz,计数器的位数为16位。因此,TIM1的计数范围是0到65535(2的16次方减1)。
在这个例子中,TIM1的自动重载寄存器(ARR)的值为999,这意味着TIM1的计数器CNT将从0开始计数,当计数器CNT增加到999时,TIM1的自动重载寄存器(ARR)会重新加载计数器CNT,计数器CNT重新从0开始计数。
因此,TIM1的计数时间可以计算为:
计数时间 = (ARR + 1) / TIM1时钟频率 = (999 + 1) / 72MHz = 13.89us
也就是说,TIM1的计数器CNT每13.89us增加1。
阅读全文
相关推荐
















