完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
有人能解释一下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个回答
|
|
你的问题缺乏上下文,你如何使用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). |
|
|
|
谢谢您。没错,我用的就是你描述的方式。但是,数据表中的何处是如何计算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. |
|
|
|
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 |
|
|
|
好的,但是这是1:1预分频器。其他预分频器值与这个公式有什么关系?
以上来自于百度翻译 以下为原文 ok, but this would be for 1:1 prescaler..how are other prescaler values related to this formula ? |
|
|
|
I预分频器只将时钟分为定时器。因此,如果它将时钟除以四,则需要四倍的时钟周期,直到定时器翻转到零为止。因此,加载它:(0x10000 -(y /预分频器)。
以上来自于百度翻译 以下为原文 I prescaler just divides down the clock coming in to the timer. So, if it is dividing the clock by four, it takes four times as many clock cycles until the timer rolls over back to zero. So, load it with: (0x10000 - (Y / prescaler) |
|
|
|
您需要知道的一切都在数据表中的“图5-1”中显示。http://www. McCypC./.. p;文件名=Time1a. PngEngress,您不使用GiSvshttp://www. MICROCHOC./..…p;文件名=Time1B.PNGSO,计时器由“FoC/C 4”计时,除以预分频器,为1, 2, 4或8。当定时器超过16位时,它会导致中断,即从0xFFF计数到0x000,在第十七位丢失之前,它可以被视为0x10000。
以上来自于百度翻译 以下为原文 Everything you need to know is shown in "Figure 5-1" in the datasheet. http://www.microchip.com/...p;filename=timer1a.png Removing the bits you are not using gives http://www.microchip.com/...p;filename=timer1b.png So, the timer is clocked by "Fosc/4", divided by the prescaler, which is 1, 2, 4, or 8. The timer causes an interrupt when it overflows 16 bits, i.e. it counts from 0xFFFF to 0x0000, which can be regarded as 0x10000 before the 17th bit is lost. Everything I said above can be determined from this. |
|
|
|
只有小组成员才能发言,加入小组>>
5166 浏览 9 评论
2000 浏览 8 评论
1928 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3174 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2226 浏览 5 评论
734浏览 1评论
615浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
505浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
631浏览 0评论
528浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-24 15:35 , Processed in 1.183355 second(s), Total 57, Slave 50 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号