如何将 ISR 上的预分频器设置为以微秒为单位的特定间隔?
我有一个 PIC18F87J11 设备,我应该创建:
1) 高优先级 ISR,应该每 100 毫秒触发一次
2) 一个低优先级 ISR,应该每 10ms 触发一次
我有关于配置预分频器的基本知识,例如对于 Timer0,它是
movlw b'00000010'
movwf T0CON
手册页读取的内容,这应该将 Timer0 配置为 16 位计数器,预分频器 1:8(设备手册第 179 页)。问题是,当我想要 100ms 间隔时,我不知道如何确定正确的预分频器设置。 任何帮助表示赞赏。
编辑:
好吧,现在我意识到我对自己在做什么的了解可能比我想象的要少得多。我在 手册 中找不到相关信息(并且我'我确定它在那里)。我需要将 Timer0 设置为 100ms,将 Timer1 设置为 10ms。
I have a PIC18F87J11 device and I'm supposed to create:
1) a high-priority ISR that's supposed to be triggered every 100ms
2) a low-priority ISR that's supposed to be triggered every 10ms
I have a basic knowledge about configuring a pre-scaler, in example for Timer0, it's
movlw b'00000010'
movwf T0CON
as manual page reads, this should configure Timer0 to 16bit counter, pre-scaler 1:8 (device's manual page 179). The problem is, I don't know how to determine the correct pre-scaler settings when I want 100ms intervals.
Any help appreciated.
EDIT:
Okay, now I realize that I probably have way less idea about what I'm doing then I thought. I can't find relevant information in manual (and I'm sure it is there). I need to set up Timer0 to 100ms and Timer1 to 10ms.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是 TMR0 的 ISR 高优先级启动程序。
在 MCPU 启动代码的一开始,您必须定义...
MCPU 启动后,不要忘记打开中断...
ISR rutine:
在 ISR rutune 中计数 TMR0 溢出的数量,对于 10MHz CPU 时钟:10000000 / 4 / 1024 = 2441.4 溢出一秒。
我建议您仅使用一个 ISR 例程来处理这两个事件。
Here are you have ISR high-priority initiation rutine for TMR0.
At very begining of your MCPU initiation code you must define...
After MCPU initiation don't forget to switch on interrupts...
ISR rutine:
In ISR rutune count numbers of TMR0 overflows, for 10MHz CPU clock: 10000000 / 4 / 1024 = 2441.4 overflows for one second.
I recommend that you are using only one ISR rutine where you handle both events.