完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
大家好,我正在使用一个PIC24EP256GP206,我想使用OC MODUL来产生一个输出脉冲内径比较单输出脉冲模式,每次从TMR2接收IRQ。如果我选择FCY作为OC1的输入时钟,它工作,但是当我选择TMR3作为输入时钟时,它只产生一个输出脉冲。我不理解原因。这是代码:这是IRQS代码:我也尝试了StunGoC1CON2BITS SysCSEL=0x0D(time3同步或触发器),但没有变化。它为什么只工作iFiC1CONBITE?OCTSEL=7?有人能帮我吗?谢谢
以上来自于百度翻译 以下为原文 Hi All, i'm working with a PIC24EP256GP206, I want to use OC modul to generate an output pulse in DUAL COMPARE SINGLE OUTPUT PULSE MODE, every time I receive an irq from TMR2. If I select Fcy as input clock for OC1 it works, but when I choose TMR3 as input clock, it generates only one output pulse and I don't understand the cause. This is the code: // INITIALIZATION ******************************* // TMR2 TMR2 = 0; T2CONbits.TSIDL = 0; T2CONbits.TGATE = 0; T2CONbits.TCKPS = 3; // Prescaler = 256 T2CONbits.TCS = 0; IPC1bits.T2IP = 4; IFS0bits.T2IF = 0; IEC0bits.T2IE = 1; PR2 = 7725; //25 ms/40Hz //*********************************************** // TMR3 (input clock for OC1) TMR3 = 0; T3CONbits.TSIDL = 0; T3CONbits.TGATE = 0; T3CONbits.TCKPS = 1; T3CONbits.TCS = 0; T3CONbits.TON = 0; //*********************************************** // OC1 (Output compare) OC1CON1 = 0; OC1CON2 = 0; RPOR1bits.RP37R = 0x10; OC1CON1bits.OCTSEL = 1; // Source = Timer3 OC1R = 2000; OC1RS = 2500; OC1CON2bits.SYNCSEL = 0; OC1CON2bits.OCTRIG = 0; OC1CON2bits.TRIGSTAT = 0; IPC0bits.OC1IP = 1; IFS0bits.OC1IF = 0; IEC0bits.OC1IE = 1; PR3=OC1RS+2; T2CONbits.TON = 1; This is the IRQs code: void __attribute__((interrupt, no_auto_psv)) _T2Interrupt(void){ TMR2 = 0; TMR3 = 0; OC1TMR = 0; OC1CON1bits.OCM = 4; // ReARM a new output pulse T3CONbits.TON = 1; IFS0bits.T2IF = 0; } void __attribute__((interrupt, no_auto_psv)) _OC1Interrupt(void){ T3CONbits.TON = FALSE; IFS0bits.OC1IF = 0; } I tried also setting OC1CON2bits.SYNCSEL = 0x0D (Timer3 synchronizes or triggers) but nothing change. Why does it work only if OC1CON1bits.OCTSEL=7 ? Can anyone help me? Thanks |
|
相关推荐
6个回答
|
|
如果从T2改为T3,则应禁用OC,更改然后重新启用。如果使用中断,则还需要T3 ISR。
以上来自于百度翻译 以下为原文 If you change from t2 to t3, you should disable OC, change then re-enable. You'd also need a t3 isr if using interrupts. |
|
|
|
如果你看AL看我发布的代码,首先我设置TMR2和TMR3,而不是我设置OC,最后我启用TMR2。我启用OC只在TMR3 IRQ。怎么了?谢谢
以上来自于百度翻译 以下为原文 If you take al look at the code I posted, first I set tmr2 and tmr3, than I set OC, and finally I enable tmr2. I enable OC only in the tmr3 irq. What's wrong? Thanks |
|
|
|
这个问题仍然让我感到厌烦。有人能告诉我如何设置OC来正确使用TMR2或TMR3时基吗?谢谢
以上来自于百度翻译 以下为原文 This trouble is still boring me. Could someone explain me how to setup OC to work properly with TMR2 or TMR3 timebase? Thanks |
|
|
|
最后一周做的
以上来自于百度翻译 以下为原文 Done it last exact week OC1CON1 = 0x0400; // src=Timer3 OC1CON1 = 0x1c00; // src=SysClk |
|
|
|
是的,我理解,但是设置“双比较单输出脉冲”,与TMR3,它只产生第一个脉冲,而用FCY它产生所有的脉冲(在重新武装OCCON。OCM=4)。为什么??
以上来自于百度翻译 以下为原文 yes, I understand, but setting "dual compare single output pulse", with tmr3, it generates only the first pulse whereas with Fcy it generates all pulses (after rearm OC1CON.OCM=4). Why?? |
|
|
|
对不起,我从来没有尝试过……实际上我所面临的另一件奇怪的事情,就是“与自己同步”:我不确定它是否需要,而且数据表对我来说不太清楚。尽管如此,以上工作!
以上来自于百度翻译 以下为原文 Sorry, I never tried that... There's actually another strange thing that I faced, that is the "sync with itself": am not sure if it's needed or not, and the datasheet is not too clear to me. Nonetheless the above work! |
|
|
|
只有小组成员才能发言,加入小组>>
5250 浏览 9 评论
2037 浏览 8 评论
1958 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3218 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2266 浏览 5 评论
788浏览 1评论
680浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
609浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
685浏览 0评论
582浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-28 23:15 , Processed in 1.620913 second(s), Total 87, Slave 72 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号