引用:
2009年12月15日10:39,Anonymous写道:
嗨jeffrey.chang168,
如RM0016中所述,TIM4是自动重载向上计数器计时器。
下面是对理论的解释!
// TIM4_TimeBaseInit(TIM4_PRESCALER_128,128); // (一个)
如果以默认系统时钟配置(2MHz)运行系统,则TIM4计数器的时钟频率为2000000 /预分频器= 2000000/128 = 15 625 Hz,因此每次产生更新中断(128 + 1)/ 15625 = 8.256 ms
TIM4_TimeBaseInit(TIM4_PRESCALER_128,16); //(B)
如果以默认系统时钟配置(2MHz)运行系统,则TIM4计数器的时钟频率为2000000 /预分频器= 2000000/128 = 15 625 Hz,因此每次生成更新中断(16 + 1)/ 15625 = 1.088 ms
如果仍然不清楚,请告诉我。
问候,
如RM0016第239页中所述,TIM4中断是在计数器溢出时产生的。所以UP计数器在溢出时自动重载。
情况A)128,129,...,255,0,128
因此,中断周期A应为(256 - 128)/ 15625 = 128/15625。
案例B)16,17,......,255,16
因此中断周期B应为(256 - 16)/ 15625 = 240/15625。
期间A< B期
//////////////////////////////////////
如果TIM4是自动重载DOWN计数器。
情况A)128,127,...,1,0,128
因此,中断周期A应为(128 + 1)/ 15625 = 129/15625。
案例B)16,15,...,1,0,16
因此,中断周期应为(16 + 1)/ 15625 = 17/15625。
期间A> B期
哪一个是正确的?
[此消息由以下人员编辑:jeffrey.chang168于15-12-2009 16:59发表]
以上来自于谷歌翻译
以下为原文
Quote:
On 15-12-2009 at 10:39, Anonymous wrote:
Hi jeffrey.chang168,
As mentioned in the RM0016, the TIM4 is auto-reload up-counter timer.
An below the explanation of the theory !
//TIM4_TimeBaseInit(TIM4_PRESCALER_128, 128); // (A)
If you are running your system in the default system clock configuration (2MHz), the TIM4 counter is clocked by 2000000 / prescaler = 2000000 / 128 = 15 625 Hz so update interrupt is generated each (128 + 1) / 15625 = 8.256 ms
TIM4_TimeBaseInit(TIM4_PRESCALER_128, 16); // (B)
If you are running your system in the default system clock configuration (2MHz), the TIM4 counter is clocked by 2000000 / prescaler = 2000000 / 128 = 15 625 Hz so update interrupt is generated each (16 + 1) / 15625 = 1.088 ms
Let me know if that stills unclear.
Regards,
As mentioned in RM0016 page 239, the TIM4 interrupt is generated on counter overflow. So the UP counter is auto-reload on overflow.
Case A) 128, 129, ..., 255, 0, 128
so Interrupt Period A should be (256 - 128) / 15625 = 128/15625.
Case B) 16, 17, ..., 255, 16
so Interrupt Period B should be (256 - 16) / 15625 = 240/15625.
Period A < Period B
//////////////////////////////////////
If TIM4 is auto-reload DOWN counter.
Case A) 128, 127, ..., 1, 0, 128
so Interrupt Period A should be (128 + 1) / 15625 = 129/15625.
Case B) 16, 15, ..., 1, 0, 16
so Interrup Period should be (16 + 1) / 15625 = 17/15625.
Period A > Period B
Which one is correct ?
[ This message was edited by: jeffrey.chang168 on 15-12-2009 16:59 ]
引用:
2009年12月15日10:39,Anonymous写道:
嗨jeffrey.chang168,
如RM0016中所述,TIM4是自动重载向上计数器计时器。
下面是对理论的解释!
// TIM4_TimeBaseInit(TIM4_PRESCALER_128,128); // (一个)
如果以默认系统时钟配置(2MHz)运行系统,则TIM4计数器的时钟频率为2000000 /预分频器= 2000000/128 = 15 625 Hz,因此每次产生更新中断(128 + 1)/ 15625 = 8.256 ms
TIM4_TimeBaseInit(TIM4_PRESCALER_128,16); //(B)
如果以默认系统时钟配置(2MHz)运行系统,则TIM4计数器的时钟频率为2000000 /预分频器= 2000000/128 = 15 625 Hz,因此每次生成更新中断(16 + 1)/ 15625 = 1.088 ms
如果仍然不清楚,请告诉我。
问候,
如RM0016第239页中所述,TIM4中断是在计数器溢出时产生的。所以UP计数器在溢出时自动重载。
情况A)128,129,...,255,0,128
因此,中断周期A应为(256 - 128)/ 15625 = 128/15625。
案例B)16,17,......,255,16
因此中断周期B应为(256 - 16)/ 15625 = 240/15625。
期间A&lt; B期
//////////////////////////////////////
如果TIM4是自动重载DOWN计数器。
情况A)128,127,...,1,0,128
因此,中断周期A应为(128 + 1)/ 15625 = 129/15625。
案例B)16,15,...,1,0,16
因此,中断周期应为(16 + 1)/ 15625 = 17/15625。
期间A> B期
哪一个是正确的?
[此消息由以下人员编辑:jeffrey.chang168于15-12-2009 16:59发表]
以上来自于谷歌翻译
以下为原文
Quote:
On 15-12-2009 at 10:39, Anonymous wrote:
Hi jeffrey.chang168,
As mentioned in the RM0016, the TIM4 is auto-reload up-counter timer.
An below the explanation of the theory !
//TIM4_TimeBaseInit(TIM4_PRESCALER_128, 128); // (A)
If you are running your system in the default system clock configuration (2MHz), the TIM4 counter is clocked by 2000000 / prescaler = 2000000 / 128 = 15 625 Hz so update interrupt is generated each (128 + 1) / 15625 = 8.256 ms
TIM4_TimeBaseInit(TIM4_PRESCALER_128, 16); // (B)
If you are running your system in the default system clock configuration (2MHz), the TIM4 counter is clocked by 2000000 / prescaler = 2000000 / 128 = 15 625 Hz so update interrupt is generated each (16 + 1) / 15625 = 1.088 ms
Let me know if that stills unclear.
Regards,
As mentioned in RM0016 page 239, the TIM4 interrupt is generated on counter overflow. So the UP counter is auto-reload on overflow.
Case A) 128, 129, ..., 255, 0, 128
so Interrupt Period A should be (256 - 128) / 15625 = 128/15625.
Case B) 16, 17, ..., 255, 16
so Interrupt Period B should be (256 - 16) / 15625 = 240/15625.
Period A < Period B
//////////////////////////////////////
If TIM4 is auto-reload DOWN counter.
Case A) 128, 127, ..., 1, 0, 128
so Interrupt Period A should be (128 + 1) / 15625 = 129/15625.
Case B) 16, 15, ..., 1, 0, 16
so Interrup Period should be (16 + 1) / 15625 = 17/15625.
Period A > Period B
Which one is correct ?
[ This message was edited by: jeffrey.chang168 on 15-12-2009 16:59 ]
举报