完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
亲爱的各位,我在DSPIC33 E中使用IC模块作为跟随者4代码如下:在每第四个边、第二个边、第四个边、第二个边等上,用LeD3(Twitter)来中断。FoSC=80MHZOfc= 40MHZalSOON,请某人解释IC1BUF(FIFO)。它是如何工作的。为什么我们在内部中断了2次?范围PIC:黄色是输入信号,蓝色是中断目标:测量蓝色中断之间的时间-最小频率=0.83Hz(1200毫秒)和马克斯FRQ= 83.33赫兹(12ms)。
以上来自于百度翻译 以下为原文 Dear all, I use IC module in dspic33e as follows unsigned int Capture1, Capture2; unsigned int counts; unsigned long timeperiod = 0; void Hall_Capture(void) { TRISHALL=1; ANSELHALL=0; RPINR7bits.IC1R=0b0110011; IFS0bits.IC1IF = 0; // Clear the IC1 interrupt status flag IEC0bits.IC1IE = 1; // Enable IC1 interrupts IPC0bits.IC1IP = 1; // Set module interrupt priority as 1 IC1CON1bits.ICSIDL = 0; // Input capture will continue to operate in CPU idle mode IC1CON1bits.ICTSEL = 0b010; // T4 is the clock source for the IC1 module IC1CON1bits.ICI = 0b00; // Interrupt on every capture event IC1CON1bits.ICBNE = 0; // Input capture is empty IC1CON1bits.ICM = 0b100; // Capture mode; every fourth rising edge (Prescaler Capture mode) IC1CON2bits.IC32 = 0; // Cascade module operation is disabled IC1CON2bits.ICTRIG = 0; // Input source used to synchronize the input capture timer of // another module (Synchronization mode) IC1CON2bits.TRIGSTAT = 0; // IC1TMR has not been triggered and is being held clear IC1CON2bits.SYNCSEL = 0b0; // No Sync or Trigger source for the IC1 module } void __attribute__ ((__interrupt__, no_auto_psv)) _IC1Interrupt(void) { Capture1 = IC1BUF; // Read and save off first capture entry Capture2 = IC1BUF; // Read and save off second capture entry LED3=~LED3; //LED3^=1; IFS0bits.IC1IF = 0; // Reset respective interrupt flag if(Capture1>Capture2) Timeperiod= Capture2-Capture1; else Timeperiod= (TMR4-Capture1)+Capture2; } timer 4 code as follows T4CONbits.TON = 0; // Disable Timer T4CONbits.TCS = 0; // Select internal instruction cycle clock T4CONbits.TGATE = 0; // Disable Gated Timer mode T4CONbits.TCKPS = 0b00; // Select 1:1 Prescaler TMR4 = 0x00; // Clear timer register PR4 = 0xFFFF; /*one interrupt happens in 1 ms PR4=(1/(Fcy/8))*5000=0.001s */ IPC6bits.T4IP = 0x01; // Set Timer4 Interrupt Priority Level IFS1bits.T4IF = 0; // Clear Timer4 Interrupt Flag IEC1bits.T4IE = 1; // Enable Timer4 interrupt T4CONbits.TON = 1; // Enable Timer4 I see interrupt on by Led3(toggle) on every 4th edge, 2nd edge,4th edge, 2nd edge and so on. Fosc=80Mhz Fosc=40Mhz Also Please, someone, explain IC1BUF (FIFO) . How it works. ? Why we read 2 times inside interrupt.? Scope Pic: Yellow is the input signal and Blue is the interrupt Goal: measuring the time between Blue interrupts- Min freq.=0.83hz(1200ms) and Max freq=83.33hz(12ms) |
|
相关推荐
7个回答
|
|
|
|
|
|
你可以检查这个线程,但是用定时器3代替定时器4。http://www. McCux.com……?M=1033369和FP=1
以上来自于百度翻译 以下为原文 You can check this thread.But With Timer 3 instead of Timer 4. http://www.microchip.com/...spx?m=1033369&fp=1 |
|
|
|
测量范围的计算:(FoCC/2/TimePrimeCalor)/时间周期TimeReal= CaseTe2捕获1,只需要在ISR中捕获1和捕获2,在主函数中进行REST DO计算。希望这有助于…——TS9
以上来自于百度翻译 以下为原文 Calculation for measurement range: (Fosc/2/Timerprescaler) /Timeperiod Where Timerperiod= Capture2-Capture1 You need only take Capture1 and Capture2 in ISR and rest do calculation in main function. Hope this helps... -- TS9 |
|
|
|
我已经编程4上升沿后,它捕获,因此中断。谁能告诉我为什么中断(蓝色)正在发生4上升沿然后2上升沿……等等?(参考:范围图片)
以上来自于百度翻译 以下为原文 I have programmed after 4 rising edge it makes a capture and hence an interrupt. Can anyone tell me why interrupt(Blue) is happening 4 rising edge then 2 rising edge....and so on? :( Refer: Scope Picture |
|
|
|
在30F6010A上有一个类似的代码,最后我做了两个虚拟的ICXBUF读取,以完全中断每个FIFO的中断。这可能会有帮助,特别是如果你的信号有一些开关跳动或噪音。
以上来自于百度翻译 以下为原文 With a similar bit of code on a 30f6010A I ended up doing a couple of dummy reads of icxbuf to completely empty the FIFO each interrupt. This may help, especially if you have some switch bounce or noise on your signal. |
|
|
|
注意你的术语。我很不确定你想在那里解释什么。显然你现在使用“编程”和“捕获”来解决你的软件问题和你的范围。我不知道为什么/你如何产生你的“蓝色”中断输出。当你看LED的时候感觉很好,但是没有那么有趣。如果它真的只是你的LED切换,那么我会把它变成LED上的入口,然后在ISR的出口上被引导。这只是显示ISR在输入信号的上升沿上被调用。但是你看不到,ISR是否仍然繁忙,根本无法检测到额外的输入变化。
以上来自于百度翻译 以下为原文 Be careful with your terminology. I'm quite unsure what you want to explain there. Apparently you now use "programming" and "capture" for both your software problem and for your scope. I'm not sure why / how you generate your "blue" interrupt output. Nice when just looking at the LED but not so interesting for the scope. If it's really just your LED toggle, then I would have changed that to LED ON on entry and LED OFF on exit of the ISR. Currently LED3=~LED3;this just shows that the ISR is invoked on rising edges of your input signal. But you cannot see, whether the ISR is still busy and simply cannot detect additional input changes. |
|
|
|
谢谢你提供的信息。但真的是,只要切换一个LED需要这么长的时间,ISR仍然繁忙!!!!我故意慢慢地输入这个输入边沿,这样我就可以看到每隔第四个边出现中断。但它并不是一直都在流行。我预计每第四个上升沿应该有一个中断。
以上来自于百度翻译 以下为原文 Thanks for the info. But is it true that just for toggling a LED takes so much time that ISR is still busy!!! I am deliberately feeding this input edge slowly so that I could see that interrupt occurs on every 4th edge. But it doesn't happen all the time. I expect on every 4th rising edge there should be an interrupt. |
|
|
|
只有小组成员才能发言,加入小组>>
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 13:58 , Processed in 1.393418 second(s), Total 94, Slave 76 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号