完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
|
我用MCC定时器2/3配置为32位定时器,预SCALTETCKPS 1:64,TCS使用内部时钟FoC/2,ON。我只有一个二次振荡器(RTC),主振荡器与它同步。所有寄存器由MCC正确初始化,但定时器I初始化。在调试模式下,如果我关机(切换)吨位,没有任何变化,仍然不工作。如果我切换TCS位,然后定时器2开始工作。我读了勘误表,这是没有什么。你认为正在发生什么?我做错什么了?谢谢你的帮助!Stephane。
以上来自于百度翻译 以下为原文 Hello Using a PIC24FJ256GB406. I configured using MCC timer 2/3 to be a 32 bit timer, pre-scaler TCKPS 1:64, TCS using Internal Clock Fosc/2, and ON. I only have a Secondary oscillator (RTC), the primary oscillator being synchronized with it. All registers get correctly initialized by MCC but the Timer is NOT working. In debug mode, if I turn off and on (toggle) the TON bit, nothing changes, still not working. If I toggle the TCS bit then Timer 2 starts working. I read the errata, there is nothing about this. What do you think is happening? What did i do wrong? Thank you for your help! Stephane. |
|
相关推荐
17个回答
|
|
|
这意味着什么?16位模式工作?你的照片上还有其他定时器吗?当你不使用MCC时它会起作用吗?在我的PIC24FJ256GB406,设备ID:6114,Rev:2,即32位定时器4/5,正在运行(在应用程序中读取TMR4和TMR5寄存器)。这个代码与32位定时器2/3(简单地调整SFRs)一样,您如何测试?你怎么知道计时器坏了?你看到了什么?
以上来自于百度翻译 以下为原文 What does this mean ? 16 bit mode works ? Any other timer worked before on your PIC ? It works when you do not use MCC ? This code works (counting 32 bits as expected) on my PIC24FJ256GB406, Device ID: 6114, Rev: 2. I.e. 32 bit timer 4/5 and is running (reading TMR4 and TMR5 registers in application). Same with 32 bit timer 2/3 (simply adjust SFRs) void TMR4_Initialize (void) { //TMR5 0; TMR5 = 0x0000; //PR5 49; PR5 = 0x0031; //TMR4 0; TMR4 = 0x0000; //Period = 1.6383995 s; Frequency = 16000000 Hz; PR4 65535; PR4 = 0xFFFF; //TCKPS 1:8; T32 32 Bit; TON enabled; TSIDL disabled; TCS FOSC/2; TECS SOSC; TGATE disabled; T4CON = 0x8018; tmr4_obj.timerElapsed = false; } How do you test ? How to you know the timer is not working ? What do you see ? |
|
|
|
|
|
Heloi在16位使用定时器4,它没有任何问题。我已经在其他图片上使用这些定时器,如PIC24FJ256GB106。我看它不起作用,因为与它相关的代码(MiWi Microchip)刚刚被卡住,然后调试我在表中显示计时器寄存器,它们REM。AsN 0的价值。
以上来自于百度翻译 以下为原文 Hello I use Timer 4 in 16 bits and it is working with no issue. I have been using those timers the same way on other PICs like PIC24FJ256GB106. I see it not working because the code associated to it (MiWi Microchip) just was stuck then debugging I displayed the Timers registers in the Watches, they remains 0 value. Stephane. |
|
|
|
|
|
由于您不提供任何代码,所以不可能在那里看到任何问题。你说这是正确的…你不应该完全依赖于MCC,但是计时器并不那么困难。当使用(暂停)调试器和外围设备显示时,我会很小心。不要依赖SFR定时器值,如预期的那样更新。或者验证你的调试方法和你的Time4测试是否很好:你正确设置PR了吗?FOsc的价值是什么?2.尝试设置开始值!= 0,因此在调试器中可以看到,如果它是“常数”或已经改变。0总是有点特殊。对于一个简单的测试,不要使用32位模式,而是使用你的16位定时值的被证明的初始化值。它很可能不与16位相反的32位,它只是从已知的工作开始。也可以使用我的init值从上面(改为Time2/2)。
以上来自于百度翻译 以下为原文 Since you do not provide any code it's not possible to see any problem there. You said that it's correct... You should never fully rely on MCC, however timers are not that difficult. I would be careful when using (halted) debugger and what the peripherals display. Do not rely on SFR timer values beeing updated as you expect. Or verify that your debugging method works well with e.g. your Timer4 Some tests: Did you set PR correctly ? What is the value of FOsc/2. Try setting start values != 0, so that in the debugger you can see, if it's "constant" or has changed. 0 is always somewhat special. For a test simply do not use 32 bit mode, but use your proved initialization values for 16 bit Timer4. It very likely has not to do with 16 versa 32 bit, it's just to start with something that is known to work. Also you could use my init values from above (changed to Timer2/3) |
|
|
|
|
|
HeloSoRRY我可以提供代码。请注意我在调试中检查了T2CON寄存器,对我来说是正确的设置。频率FoSc/ 2是16MHz(最大速度)。这里是MCC生成代码:然后我更新了微芯片“符号C”,使用MCC生成函数并评论了它们。DE:TMR2AUT32比特GET()总是返回0(直到我切换TCS位)。非常感谢您的帮助!Stephane。
以上来自于百度翻译 以下为原文 Hello Sorry I can provide the code. Please note I checked the T2CON register in debugging and for me it is correctly setup. Frequency Fosc/2 is 16MHz (maximum speed). Here is the mcc generated code: void TMR2_Initialize (void) { //TMR3 0; TMR3 = 0x0000; //PR3 0; PR3 = 0x0000; //TMR2 0; TMR2 = 0x0000; //Period = 0 s; Frequency = 16000000 Hz; PR2 0; PR2 = 0x0000; //TCKPS 1:64; T32 32 Bit; TON enabled; TSIDL disabled; TCS FOSC/2; TECS SOSC; TGATE disabled; T2CON = 0x8028; tmr2_obj.timerElapsed = false; } Then I updated the Microchip "symbol.c" as following to use mcc generated function and commented their code: MIWI_TICK MiWi_TickGet(void)//TO BE TESTED { MIWI_TICK currentTime; currentTime.Val = TMR2_Counter32BitGet(); /* currentTime.word.w1 = TMR3; currentTime.word.w0 = TMR2; if( currentTime.word.w1 != TMR3 ) { currentTime.word.w1 = TMR3; currentTime.word.w0 = TMR2; }*/ return currentTime; } TMR2_Counter32BitGet() always return 0 (until I toggle the TCS bit). Thank you very much for your help! Stephane. |
|
|
|
|
|
不幸的是,我看不出你和我的代码/设置之间有什么逻辑上的区别。你的PIC是从我假设的主振荡器运行的。由于Time2/3用SOSC运行,基本配置似乎可以。您所说的频率FoSc/ 2是16 MHz,那么,我不理解FRM手册中的图13-1所示的注释,那么只有STEP会有问题吗?然而,为什么定时器4工作(你所说的)。
以上来自于百度翻译 以下为原文 Unfortunately I cannot see any logical difference between your and my code/settings. Your PIC is running from the main oscillator I assume. Since the Timer2/3 runs with SOSC, the basic configuration seems to be ok. You said Frequency Fosc/2 is 16 Mhz,- then I did not understand this comment Looking at Figure 13-1 in the FRM manual, then only TCy could have some problem ? However then why should Timer 4 work (what you said). |
|
|
|
|
|
只是一张纸条,这不是用模拟器测试的,是吗?过去我在PIC24上有一些问题,其中一些计时器正确地模拟了,而其他的则没有。
以上来自于百度翻译 以下为原文 Just a note, this is not being tested with SIMulator, is it? I had some issues in the past on PIC24, where some Timers where simulated correctly and others did not... |
|
|
|
|
|
Heloi在实际的板上调试,而不是模拟器。我正在使用PIC的奇妙的新特性,在这里你可以使用内部振荡器并与二级振荡器同步。我只有一个石英的二次振荡器,我仍然有一个精确的主时钟符合USB的要求。我猜是有一些种族条件,定时器4是按预期的工作。如果我切换TCS,Time2/3开始工作,看起来像是一种bug或者其他错误地初始化阻止定时器的东西。非常感谢你的帮助和耐心。
以上来自于百度翻译 以下为原文 Hello I am debugging on the real board, not the simulator. I am using that wonderfully new feature of that PIC where you can use the Internal Oscillator and synchronize it with the secondary oscillator. I so just have one quartz for the secondary oscillator and I still get a precised Primary clock compliant with USB requirements. I am guessing there are some kind of race conditions, Timer 4 is working as expected. If I toggle TCS, Timer2/3 starts working, looks like a kind of bug or something somewhere else wrongly initialized blocking the timer. Thank you very much for your help and patience. Stephane. |
|
|
|
|
|
Heloi只是改变了初始化,使PR2=PR3=0xFFFF(我不需要),它工作了…谢谢你。
以上来自于百度翻译 以下为原文 Hello I just changed the initialization to have PR2 = PR3 = 0XFFFF (which I should not need) and it works... Thank you Stephane. |
|
|
|
|
|
嗯,我不确定,当(边沿或电平)比较器将重置计数器.HTTPS://imgur.COM/A/WVELIT可以是将PRX设置为0的RISY。我现在还明确地测试了初始化,它计数应该像它,但可能是如你所说的,这是一些竞赛条件。我用晶体振荡器。
以上来自于百度翻译 以下为原文 Well, I'm not sure, when (edge or level) the comparator will reset the counter. https://imgur.com/a/Wfall It could be riscy to set PRx to 0 however. I now also explicitly tested with initialization TMR3 = 0x0000; PR3 = 0; TMR2 = 0x0000; PR2 = 0; //TCKPS 1:8; T32 32 Bit; TON enabled; TSIDL disabled; TCS FOSC/2; TECS SOSC; TGATE disabled; T2CON = 0x8018; and it counts like it should, but may be as you said that is some race condition. I use primary oscillator with crystal. |
|
|
|
|
|
PRX=0被记录为一种特殊情况(它不会产生中断),但没有记录定时器在这种情况下的行为。你期待PRX=0的行为是什么?
以上来自于百度翻译 以下为原文 PRx = 0 is documented as a special case (it won't generate interrupts) but it's not documented how the timer would otherwise behave in this case. What were you expecting the behavior to be with PRx = 0? |
|
|
|
|
|
作为一个侧重点,既然我们现在在这,我想知道,如果你可以从一个定时器(当然,时钟是140MHz)来获得70MHz的IRQ(给DMA),我的意思是,如果我把PR设置为1,我可能会看到35MHz IRQ…我想试试0。但我想这行不通!(THX和对不起)
以上来自于百度翻译 以下为原文 As a side note, since we're at it now, I was wondering these days if you can achieve 70MHz IRQs (to feed the DMA) from a Timer (given of course that Clock is 140MHz) or not. I mean, If I set PR to 1 I will possibly see 35MHz IRQs... and I was going to try 0. But I suppose it won't work! (thx and sorry) |
|
|
|
|
|
HELOPrx=0,因为不需要。我只需要计时器。没有理由设置PRX.斯蒂芬。
以上来自于百度翻译 以下为原文 Hello PRx = 0 because not needed. I just need the timer. There was no reason to set PRx. Stephane. |
|
|
|
|
|
你不能“禁用”周期寄存器,它是计时器的一个组成部分。如果你希望计时器在翻转前计算它的全范围,你就不需要修改周期寄存器。这就是为什么它的默认值是0xFFFF。
以上来自于百度翻译 以下为原文 You can't "disable" the period register; it's an integral part of the timer. If you want the timer to count its full range before rolling over, you don't modify the period register. That's why its default is 0xFFFF. |
|
|
|
|
|
Heloi在文档中没有看到任何关于Prx=0的事实被禁止。
以上来自于百度翻译 以下为原文 Hello I do not see anything in the documentation about the fact PRx = 0 is forbidden. Also MCC just set it to 0. Stephane. |
|
|
|
|
|
HM,事实上,MCC(PIC24 V1.35.1)以默认值为0,32位定时器具有TMR3、PR3、TMR2、PR2.HTPSP//IMGURR.COM/A/GPR2i,这就是代码所做的。但是,我仍然不使用它0。我永远不会完全依赖MCC
以上来自于百度翻译 以下为原文 Hm, indeed the MCC (PIC24 v1.35.1) starts with default values of 0 for a 32 bit timer with TMR3, PR3, TMR2, PR2. https://imgur.com/a/gyp2i and that's what the code does. Still I would not use it with 0 [edit: ... and I would never fully rely on MCC] |
|
|
|
|
|
我不认为数据表没有说什么是相关的。数据表所说的PR=0会发生什么?我当然不会用MCC代码作为参考——尤其是因为你发现它不起作用。
以上来自于百度翻译 以下为原文 I don't think what the data sheet doesn't say is relevant. What does the data sheet say will happen with PR = 0? I certainly wouldn't use MCC code as a reference -- especially since you found it didn't work. |
|
|
|
|
|
Hellook家伙,谢谢你的帮助和耐心,主题关闭,解决方案。
以上来自于百度翻译 以下为原文 Hello OK guys, thank you for your help and patience, subject closed, solution found. Stephane. |
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
454 浏览 0 评论
5793 浏览 9 评论
2334 浏览 8 评论
2224 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3529 浏览 3 评论
1121浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1095浏览 1评论
我是Microchip 的代理商,有PIC16F1829T-I/SS 技术问题可以咨询我,微信:A-chip-Ti
872浏览 1评论
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
466浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-1 17:48 , Processed in 1.371802 second(s), Total 72, Slave 65 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
1510