完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
您好,我需要您的帮助与一个奇怪的问题:我有一个非常简单的设置与PIC24FJ256GB206,它测量风扇的转速使用IC模块。此外,我有(未修改)微芯片USB堆栈(V2.9J)作为CDC设备在中断模式下运行(不轮询)。当我拔下USB PORT,我经常从IC模块得到错误的测量结果。它们并不是完全错误的,但是两个脉冲之间的测量周期大约是实际值的1.5倍。我设置IC模块的方式是每秒上升沿产生一个中断。在IC中断期间,从FIFO中的两个定时器值计算周期(参见下面的代码)。很简单,很基础。工作完全稳定24/7直到USB电缆被拔掉。现在我甚至不知道从哪里开始寻找这个问题。USB模块实际上是如何干扰IC模块的?它是如何在测量中产生延迟的?显然,必须对USB堆栈做些什么;如果我禁用了附加/分离检测,问题就不会出现(当然,USB模块是不可用的)。有什么想法吗?感谢和问候,丹尼尔
以上来自于百度翻译 以下为原文 Hello all, I need your help with a strange problem: I have a quite simple setup with a PIC24FJ256GB206 which measures the rpm of a fan using the IC module. In addition, I have the (unmodified) Microchip USB stack (v2.9j) running as a CDC device in interrupt mode (not polling). When I unplug the USB port, I often get wrong measurements from the IC module. They are not totally wrong, but the measured period between two pulses is approximately 1.5x the actual value. The way that I have set up the IC module is that an interrupt is generated every second rising edge. During an IC interrupt the period is calculated from the two timer values in the FIFO (see code below). Very simple, very basic. Works perfectly stable 24/7 until the USB cable gets unplugged. Now I don't even know where to start looking for the issue. How can the USB module actually interfere with the IC module? How does it generate the latency in the measurement I see here? It clearly has to do something with the USB stack; if I disable the attach / detach detection, the issue does not show up (but of course USB module is not usable). Any ideas? Thanks & best regards, daniel // set up IC1 module for rpm capturing (uses TIMER4) IC1CON1 = 0; IC1CON2 = 0; IC1CON1bits.ICTSEL = 0b10; // selects timer 4 IC1CON1bits.ICI = 0b01; // interrupt on every 2nd capture event IC1CON1bits.ICM = 3; // simple capture mode: capture on every rising edge IPC0bits.IC1IP = 6; // Setup Input Capture 1 interrupt with high priority IFS0bits.IC1IF = 0; // Clear the IC1 interrupt status flag IEC0bits.IC1IE = 1; // Enable IC1 interrupts // clear capture buffer while(IC1CON1bits.ICBNE) { j = IC1BUF; } . . . void __attribute__ ((__interrupt__)) _IC1Interrupt(void) { WORD per; per = IC1BUF; // last fan[0].period = IC1BUF - per; // new - last fan[0].timeout = 0; IFS0bits.IC1IF = 0; // Reset respective interrupt flag } |
|
相关推荐
3个回答
|
|
尝试将IC模块设置为比UCB模块更高的中断优先级。
以上来自于百度翻译 以下为原文 Try to set the IC module to a higher interrupt priority than the UCB module. |
|
|
|
是的,或者在轮询模式下使用USB(通常对我来说足够好。不管怎样,如果你的问题只有在断开连接的时候才会发生。
以上来自于百度翻译 以下为原文 Yeah, or use USB in polled mode (usually it's good enough to me. Anyway, if your issue only happens when *disconnected* there could be something else going on... |
|
|
|
很好的建议。由于延迟中断,FIFO可以获得额外的捕获,FIFO也可能溢出。如果FIFO不是空的,可能在每个中断中读取额外的时间。
以上来自于百度翻译 以下为原文 Good suggestions. You could be getting an extra capture in the FIFO due to the delayed interrupt and the FIFO might also overflow. Possibly read it an extra time in each interrupt if the FIFO is not empty. |
|
|
|
只有小组成员才能发言,加入小组>>
5159 浏览 9 评论
1998 浏览 8 评论
1927 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3170 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2223 浏览 5 评论
724浏览 1评论
608浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
496浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
621浏览 0评论
520浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-19 23:26 , Processed in 1.224217 second(s), Total 82, Slave 66 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号