完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我可以成功使用TIM4中断,如下代码:
// TIM4自动重载向上计数器? // TIM4_TimeBaseInit(TIM4_PRESCALER_128,128); // (一个) TIM4_TimeBaseInit(TIM4_PRESCALER_128,16); //(B) // TIM4_ITConfig(TIM4_IT_UPDATE,ENABLE); TIM4_ITConfig(TIM4_CR1_ARPE | TIM4_CR1_URS | TIM4_CR1_CEN,ENABLE); / *启用TIM4 * / TIM4_Cmd(ENABLE); 但我不确定TIM4是否作为STM8S103F3自动重载向上计数器 RM0016(第239页)文档,因为(B)语句比(A)更快地切换LED。这意味着(B)的TIM4中断周期更短。 [此消息由以下人员编辑:jeffrey.chang168于14-12-2009 15:54] [此消息由以下人员编辑:jeffrey.chang168于15-12-2009 00:12] 以上来自于谷歌翻译 以下为原文 I can use TIM4 interrupt successfully as following codes: // TIM4 auto-reload up-counter ? //TIM4_TimeBaseInit(TIM4_PRESCALER_128, 128); // (A) TIM4_TimeBaseInit(TIM4_PRESCALER_128, 16); // (B) //TIM4_ITConfig(TIM4_IT_UPDATE, ENABLE); TIM4_ITConfig(TIM4_CR1_ARPE | TIM4_CR1_URS | TIM4_CR1_CEN, ENABLE); /* Enable TIM4 */ TIM4_Cmd(ENABLE); But I am NOT sure whether the TIM4 is auto-reload up-counter as STM8S103F3 RM0016 (page 239) document since the (B) statement toggles the LED faster than the (A) one. It means that the TIM4 interrupt period of (B) is shorter. [ This message was edited by: jeffrey.chang168 on 14-12-2009 15:54 ] [ This message was edited by: jeffrey.chang168 on 15-12-2009 00:12 ] |
|
|
|
嗨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 如果仍然不清楚,请告诉我。 问候, 以上来自于谷歌翻译 以下为原文 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, |
|
|
|
引用:
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 ] |
|
|
|
嗨jeffrey.chang168,
当我开始在STM8上开发时,我想和你一样! 当计数器(CNTR寄存器)达到自动重载值(ARR寄存器)时,发生溢出事件。 这在TIM1部分解释。 计数器溢出时产生TIM4中断。所以UP计数器在溢出时自动重载。 情况A)0,1,...,128在128溢出事件 所以中断周期A是(128 + 1)/ 15625 = 8.256 ms 情况B)0,1,...,15在16溢出事件 因此中断周期B为(16 + 1)/ 15625 = 1.088 ms。 我希望现在很清楚。 问候, 以上来自于谷歌翻译 以下为原文 Hi jeffrey.chang168, I thought like you when I started developping on STM8 ! The overflow event occurs when the counter (CNTR register) reaches the Auto-Reload value (ARR register). That is explained in TIM1 section. the TIM4 interrupt is generated on counter overflow. So the UP counter is auto-reload on overflow. Case A) 0, 1, ..., 128 at 128 the overflows event so Interrupt Period A is (128 + 1) / 15625 = 8.256 ms Case B) 0, 1, ..., 15 at 16 the overflows event so Interrupt Period B is (16 + 1) / 15625 = 1.088 ms. I wish It is clear now. Regards, |
|
|
|
我如何使用TIM4进行10分钟的入侵?????????????如果知道的话,请帮帮我...谢谢
以上来自于谷歌翻译 以下为原文 how can i use TIM4 for 10 minute intruupt????????????? plz help me if any know...thanks |
|
|
|
只有小组成员才能发言,加入小组>>
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
2626 浏览 1 评论
3208 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
1782 浏览 1 评论
3607 浏览 6 评论
5987 浏览 21 评论
938浏览 4评论
1313浏览 4评论
在Linux上安装Atollic TRUEStudio的步骤有哪些呢?
581浏览 3评论
使用DMA激活某些外设会以导致外设无法工作的方式生成代码是怎么回事
1302浏览 3评论
1356浏览 3评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-20 19:42 , Processed in 1.231788 second(s), Total 83, Slave 67 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号