Microchip
直播中

王利

8年用户 198经验值
私信 关注
[问答]

PIC16F690使用timer1生成方波输出?

嗨,所有,这是MPLABX 3.05和XC8 V1.34。我试图建立一个2kHz(1 / f= 500美元)方波输出RC0使用time1。PIC使用的是内部的OSC(8MHz),后置器设置为4MHz。Time1被设置为使用内部时钟源(FoSc/4)。这应该给我一个1US(1 /t=1MHz)每一个计时器1的寄存器(对于Time1的预分频器是1∶1)。我设置计时器寄存器计数500(655 35-500=65035=0xFE0B,TMR1H=0xFE,TMR1L= 0x0B)和中断切换RC0。从RC0得到的最高频率FRQ大约是500赫兹,即使在Time1寄存器中有0xFFFE。我缺少什么?谢谢

以上来自于百度翻译


      以下为原文

    Hi all,
This is for MPLABX 3.05 and XC8 v1.34.
I'm trying to set up a 2kHz (1/f=500us) square wave output for RC0 using timer1. The PIC is using the internal osc (8MHz) with the postcaler set for 4MHz. Timer1 is set to use internal clock source (Fosc/4). This should give me a 1us (1/t=1MHz) per count of the timer1 registers (prescaler for timer1 is 1:1). I set up the timer registers to count 500 (65535-500 = 65035 = 0xfe0b, TMR1H=0xfe, TMR1L=0x0b) and the interrupt to toggle RC0.
The highest freq I can get from RC0 is about 500Hz even with 0xfffe in the timer1 registers.
What Am I missing?
Thanks

回帖(1)

王焕树

2019-5-13 15:54:49
你的描述描述了你认为你做了什么。你的代码将告诉我们你真正做了什么。注意“使用代码标签”的意思是在代码之前放置[代码],和/或代码。我把它们插入标签以使标签可见,使用代码标签意味着代码的格式将被保留,并且论坛不会将数组索引视为格式化标签。

以上来自于百度翻译


      以下为原文

   
Quoted for agreement.
Your description says what you think you have done.
You code will show us what you have really done...
 
Note "use code tags" means to place
[ code ]
before your code, and
[ /code ]
after it (but remove the embedded spaces. I inserted them to make the tags visible)
Using code tags means the format of your code will be preserved, and the forum won't treat array indices as formatting tags.
 
 
举报

更多回帖

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