Microchip
直播中

高建明

7年用户 166经验值
私信 关注
[问答]

PIC12F675的TMR1H和TMR1L是如何计算的?

有人能解释一下TMR1H和TMR1L是如何计算的吗?数据表没有解释,既不是DS31012A,也不是AN580。公式是什么?我在4MHz使用内部OSC,在异步模式下使用TMR1。

以上来自于百度翻译


      以下为原文

    Could someone please explain how is TMR1H and TMR1L calculated ? Datasheet doesn't explain, neither DS31012A or AN580. What is the formula ?? I am using internal osc at 4MHz, tmr1 in asynchronous mode.

回帖(6)

吴键洪

2018-10-10 16:40:42
你的问题缺乏上下文,你如何使用TMR1?我可以猜到,但我不需要这样做。我假设你有一个中断服务,它在每次有一个计时器中断时重新加载TMR1H和TMR1L。计时器向上计数,当计数回零时引起中断。因此,如果你想在“Y”计数之后中断,则必须加载定时器W。It(0x10000—y)(事实上,对于快速计数),在计数器中加上“(0x10000—y)”是更可靠的,在中断服务中到达代码时,它可能不为零。

以上来自于百度翻译


      以下为原文

    Your question lacks any context.
How are you using TMR1?
 
I can guess, but I shouldn't have to.
I'm assuming you have an interrupt service which reloads TMR1H and TMR1L every time there is a timer interrupt.
Timers count upwards, and cause an interrupt when the count wraps back to zero.
So, if you want an interrupt after "Y" counts, you must load the timer with (0x10000 - Y)
 
(In fact, for fast counting, it is more reliable to ADD "(0x10000 - Y)" to the value in the counter, which may not be zero by the time it gets to your code in the interrupt service).
举报

李洁

2018-10-10 17:00:12
谢谢您。没错,我用的就是你描述的方式。但是,数据表中的何处是如何计算TMR1H值的解释呢?为什么(0x10000—y)公式?如果这声音太愚蠢了,我道歉。

以上来自于百度翻译


      以下为原文

    Thank you. that is correct, i am using it exactly the way you described. But still, where in the datasheet is the explanation for how to calculate tmr1h value ? Why (0x10000 - Y) formula ? my apologies if this sound too dumb.
举报

张蕾

2018-10-10 17:07:22
TimeR1(不是Time1h,但Time1H:Time1L)的Himaimimm值是0xFFF,然后溢出到0x000,使计算从0x10000减去目标计数(注意它是17位数字)以获得正确的时钟数0xFFFF + 1 --- & 0x100100HHESHOST。

以上来自于百度翻译


      以下为原文

    Hi



Maximum value for Timer1 (not Timer1H but Timer1H:Timer1L) is 0xffff then it overflows to 0x0000
To make the calculation you subtract your target count from 0x10000 (note its a 17 bits number) to get the correct number of clocks
 
0xffff + 1 ---> 0x10000
 
 
HIH
 
Best regards
Jorge
 
举报

李洁

2018-10-10 17:15:19
好的,但是这是1:1预分频器。其他预分频器值与这个公式有什么关系?

以上来自于百度翻译


      以下为原文

    ok, but this would be for 1:1 prescaler..how are other prescaler values related to this formula ?
举报

更多回帖

发帖
×
20
完善资料,
赚取积分