完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,我正在处理PIC18L25K50设备,MPLAB 3.30和XC8 v1.33。我正在使用定时器1来测量到达引脚SOSCI(RC1)的脉冲数量,我设置定时器1如下:当我需要计数脉冲时,我重置定时器1,然后打开它,然后在另一个定时器的帮助下等待一秒钟理论上,例如,当脉冲频率在1秒内为10Hz时,应该对10个脉冲进行计数,但测量值为30。(TMR1=30)而且我总是得到测量值的三倍(20Hz,TMR1是60等)我测量的时间数据采集1秒,而且它是正确的,振荡频率也是好的(Fosc)。使用RRUTT。有什么想法或建议吗?谢谢你
以上来自于百度翻译 以下为原文 Hi. I'm working with the PIC18L25K50 device, MPLAB 3.30 and XC8 v1.33. I'm using the timer1 to measure the number of pulses arriving at pin SOSCI (RC1) I set the timer 1 as follows: T1GCON = 0x00; T1CON = 0x8E; /* TMR1CS<1:0>: = b'10' // Crystal oscillator on SOSCI/SOSCO pins T1CKPS<1:0>: = b'00' // 1:1 Prescale value = 1 SOSCEN: 1 // Dedicated secondary oscillator circuit enabled T1SYNC: 1 // Do not synchronize external clock input RD16: 1// Enables register read/write of Timer1 in one 16-bit operation TMRxON: 0 // TMR1 turn off */ When I need to count the pulses I reset the timer1, and turn on it then I wait one second with the help of another timer as follows: TMR1 = 0x00; T1CONbits.TMR1ON = 1; // and wait 1 second /******/ .... /*****/ //When one second has passed, I get the counter pulses in TMR1 // MyPulses = TMR1 T1CONbits.TMR1ON = 0; In theory, for example, when the pulse frequency is 10 Hz in a 1 second, 10 pulses should be counted But the measured value is 30. (TMR1 = 30) And I always get three times the measured value (20Hz, TMR1 is 60, etc) I measured time data acquisition of 1 second and it's correct also the oscillation frequency is OK (Fosc). I have read that there is an errata regarding the TMR1/3 but is only applicable when the timer1/3 overflow interrupt is used. Any ideas or suggestions? Thank you |
|
相关推荐
6个回答
|
|
|
|
|
|
你必须禁用二次振荡器。它扰乱了T13CKI的灵敏度和偏置,使其适合音叉夸脱晶体。你需要一个普通的施密特逻辑输入,MCP601也是运算放大器,而不是比较器。它的典型转速是2.3V/us,因此,假设5V供电,T1CKI输入将在逻辑阈值之间的临界区域花费1.3us。这超过最小周期定时器1在异步模式下可以计数的20倍,所以即使逻辑阈值之间的范围只有10%对干扰非常敏感,由于EMI或振铃,仍然有足够的时间进行几个计数,所以将时钟边缘放大到1us/div或更好(除以02U/div)看看它们看起来是否干净!
以上来自于百度翻译 以下为原文 You *MUST* disable the secondary oscillator. It messes with the T13CKI sensitivity and biassing to make it suit a tuning-fork quarts crystal. You want a normal Schmitt logic input. Also the MCP601 is an OPAMP, not a comparator. Its typical slew rate is 2.3V/us so, assuming 5V supply, the T1CKI input will spend 1.3us in the critical region between logic thresholds. That's over 20 times the minimum period Timer 1 can count in asynch mode, so even if only 10% of the range between logic thresholds is acutely sensitive to disturbances, there's enough time for a couple of counts due to EMI or ringing, so zoom in on those clock edges to 1us/div or better (ideally 0.2us/div) and see if they still look clean! |
|
|
|
谢谢你的回答。//CONFIG1H#pragma config FOSC=INTOSCIO//振荡器选择(内部振荡器)#pragma config PCLKEN=OFF//主振荡器关闭(主振荡器关闭固件控制)#pragma config FCMEN=OFF//故障安全时钟监视器(故障安全时钟监视器关闭FLUE)PrimaMatlab配置:iOSO =关闭/ /内部/外部振荡器切换(振荡器切换模式禁用)/(代码):
以上来自于百度翻译 以下为原文 Thanks for answering. // CONFIG1H #pragma config FOSC = INTOSCIO // Oscillator Selection (Internal oscillator) #pragma config PCLKEN = OFF // Primary Oscillator Shutdown (Primary oscillator shutdown firmware controlled) #pragma config FCMEN = OFF // Fail-Safe Clock Monitor (Fail-Safe Clock Monitor disabled) #pragma config IESO = OFF // Internal/External Oscillator Switchover (Oscillator Switchover mode disabled) [/code] Also: OSCCON2 = 0x00;// SOSCGO = 0 = Secondary oscillator is shut off if no other sources are requesting it. |
|
|
|
您是否已经检查过使用的辅助计时器是否配置良好?
以上来自于百度翻译 以下为原文 Have you already checked if the auxiliary timer you use to count is well configured? |
|
|
|
用探头或没有探头探头,问题是相同的。
以上来自于百度翻译 以下为原文 With the probe or without the scope probe, the problem is the same |
|
|
|
这就是你的问题。正如《咖啡评论家》所解释的:除了音叉晶体或电容耦合相当低振幅大约32KHz的正弦波之外,使用SOSCI是件麻烦事。移动您的输入到T113CKI AMD禁用二级振荡器。如果两者都需要,则更容易实现外部Pierce振荡器,将其输出和外部信号多路复用到T13CKI,并禁用辅助振荡器缓冲区。你得到RC1作为I/O,所以有一个备用引脚来控制外部多路复用器。
以上来自于百度翻译 以下为原文 That's your problem. As Coffee Critic explains: Using SOSCI for anything other than a tuning fork crystal, or a capacitively coupled fairly low amplitude approx 32KHz sinewave is asking for trouble. Move your input to T113CKI amd disable the secondary oscillator. If you need both, it would be easier to implement an external Pierce oscillator, multiplex its output and the external signal to T13CKI and keep the secondary oscillator buffer disabled. You get back RC1 as I/O so have a spare pin to control the external MUX. |
|
|
|
只有小组成员才能发言,加入小组>>
5195 浏览 9 评论
2013 浏览 8 评论
1937 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3185 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2240 浏览 5 评论
748浏览 1评论
635浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
520浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
646浏览 0评论
546浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-2 08:21 , Processed in 1.471296 second(s), Total 87, Slave 71 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号