完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我有一个特殊的错误,然后调试一个PIC32 MX150 F128D。我使用MPLAB V.3.55和XC32 V1.42。调试工具是一个MPLAB ICD3。我给一个高度稳定的时钟输入T2CK输入,频率为3999938赫兹。对于一个GPS输入一个1 PPS脉冲从GPS,测试有一个频率为1赫兹(+/-100纳秒)。T2CK脉冲计数为TMR23作为一个32位计数器。当检测到1个PPS脉冲的正侧面时,产生中断并停止计时器,并保存TMR23计数器的值。此后,再次启用定时器。问题是,当调试C代码时,我得到错误的值。通过添加一些额外的“测试”代码,我可以得到正确的值。如果在第49行设置断点,如果在47行上设置断点,则TMR23的值为3992390,则定时器TMR23具有正确的值:399、935。行为总是可重复的。当断点在第49行时的错误值可以在3992200到3992400之间变化。断点行47的值随+/-1计数而变化。差值大约为7545个脉冲,对应于大约1.89毫秒。这一定是调试器在某些情况下过早地冻结定时器的问题。有人对此有什么想法吗?我知道,我可以使用输入捕获模式,也许可以解决这个问题。但无论如何,以上是一个问题和困惑。
以上来自于百度翻译 以下为原文 I have a peculiar error then debugging a PIC32MX150F128D. I use MPLAB V.3.55 and XC32 V1.42. The debugging tool is a MPLAB ICD3. I feed a highly stable clock to T2CK input with a frequency of 3 999 938 Hz. To the INT1 I feed a 1 PPS pulse from a GPS, tested to have a frequency of 1 Hz (+/- 100 nS). The T2CK pulses are counted by TMR23 as a 32 bit counter. When a positive flank of the 1 PPS pulses is detected an interrupt is generated and the timer is stopped and the value of the TMR23 counter is saved. Thereafter the Timer is enabled again. The problem is that when debugging the C-code I get incorrect values. By adding some extra “test” code I can get the correct value. If I set a breakpoint at line 49 the TMR23 has the incorrect value of 3 992 390 If I set a breakpoint on line 47 then timer TMR23 have the Correct value: 3 999 935 The behavior is always reproducible. The error value when the breakpoint is at line 49 can vary between 3 992 200 up to 3 992 400. The value at breakpoint line 47 varies with +/- one count. The difference is about 7 545 pulses corresponding to about 1.89 mS. This must be an issue that the debugger freezes the timer prematurely in some cases. Have anybody some thoughts about this? I’m aware that I could instead use Input capture mode and perhaps solve the problem. But anyhow, the above is a problem and confusing. Bo, SM6FIE // External INT2 INTERRUPT ROUTINE *************************************************** // IsrInt2, Timer interrupt routine, priority #7 void __ISR(_EXTERNAL_1_VECTOR, IPL7SOFT) Int1Handler(void) { T2CONbits.ON = False; Nop(); // Let TMR stabilize Nop(); GpsClkRec.uiLastTmrCount = TMR2; iLaps++; // Some code for test if (iLaps > 3) { iLaps = 0; Nop(); // Line 47 } Nop(); // Line 49 TMR2 = 0; Nop(); Nop(); T2CONbits.ON = True; Nop(); Nop(); mxINT1ClearIntFlag(); } |
|
相关推荐
5个回答
|
|
谢谢你的回答。但你的解释是不正确的。原因是,当我开始执行代码时,我总是等待一段时间,所以在激活BP之前,有1个PPS脉冲(中断)通过。因此,不管我把BP放在哪里,都应该有相同的数字。此外,我做了一个小的代码变体,我用一个端口位作为外部脉冲计数器的门信号。当在使用第49行的BP时检查外部脉冲计数器值时,得到正确的值3999935,但是TMR23(GPSCKReC.UILASTMTMRCOUNT)给出不正确的值大约为3992390。当在第47行使用BP时,结果在TMR23和外部计数器(+/-1计数)上是完全相同的。
以上来自于百度翻译 以下为原文 Thanks for the answer. But your interpretation is NOT correct. The reason is that when I start execute the code I always wait a while so a number of 1 PPS pulses (interrupts) passes before activating the BP. Therefore there should be the same numbers despite where I put the BP. Furthermore, I did a slight variant of the code where I used a Port bit to act as a gate signal to an external pulse counter. When checking the external pulse counter value when using BP at line 49 I got the correct value 3 999 935 but the TMR23 (GpsClkRec.uiLastTmrCount) give an incorrect value of about 3 992 390. When using the BP at line 47 the result was exactly the same on the TMR23 and the external counter (+/- one count). |
|
|
|
NKKZZMAN:PIC32 MX150 F128D在TXCON控制寄存器中没有中断选项位上的冻结外围设备。
以上来自于百度翻译 以下为原文 @NKurzman: The PIC32MX150F128D doesn’t have the freeze peripherals on break option bit in the TXCON Control Register. |
|
|
|
调试计时器生成计数错误值,我做了一个新版本的调试尝试并修改了中断代码如下:然后我做了两个测试:A)其中一个BP在执行程序之前被设置,b)在程序执行过程中设置BP。无计时器计数错误:iValueEK〔0〕399 99 34 IValueEK〔2〕399 99 34 IValueEK〔3〕399 99 34 IValueKe[ 5 ] 399 99 33 IValueKe[ 6 ] 399 99 34 IValueKe[ 7 ] 399 99 34 IValueKe[ 8 ] 399 99 34 IValueKe[ 9 ] 399 99 34 IValueKe[10 ] 0B B,BP在执行期间设置,给出计时器计数。错误:IValueVek [ 1 ] 399 934 IValueEK [ 2 ] 399 99 34 IValueKe[ 3 ] 399 99 34 IValueKe[ 4 ] 399 99 34 IValueKe[ 5 ] 399 99 34 IValueKe[ 6 ] 3992200和lt;-错误值(在此时间帧中的BP集)IValueEK [7 ] 399 99 33 IValueKe[8 ] 399 99 33 IValueKe[9 ] 399 99 34 IValueKe[ 10 ] 0SO显然设置了BP网络。在执行过程中动态(动态)干扰导致错误结果的计时器计数。在某种程度上,BP临时设置禁止计时器的计数。如果这种行为被认为是一个错误或不可以辩论。然而,知道是好的。对我来说,这是相当混乱,我花了不必要的时间来解决它。问候,博城,SM6FIE
以上来自于百度翻译 以下为原文 Debugging timer generates count error values I did a new version of my debug attempts and modified the interrupt code as below: // External INT2 INTERRUPT ROUTINE *************************************************** // IsrInt2, Timer interrupt routine, priority #7 void __ISR(_EXTERNAL_1_VECTOR, IPL7SOFT) Int1Handler(void) { T2CONbits.ON = False; Nop // Let TMR stabilize Nop(); GpsClkRec.uiLastTmrCount = TMR2; iValueVek[iIdx] = TMR2; // Save TMR23 values into vector iIdx++; if (iIdx > 24) { iIdx = 0; } if (iIdx == 10) { Nop(); // Set breakpoint HERE } Nop(); Nop(); TMR2 = 0; Nop(); Nop(); T2CONbits.ON = True; Nop(); Nop(); mxINT1ClearIntFlag(); } Then I did two tests: A) One where the BP was set before executing the program, B) Set BP during execution of the program. Case A, BP Set before execution gives, as expected no timer counting errors: iValueVek[0] 3442455 iValueVek[1] 3999934 iValueVek[2] 3999934 iValueVek[3] 3999934 iValueVek[4] 3999933 iValueVek[5] 3999933 iValueVek[6] 3999934 iValueVek[7] 3999934 iValueVek[8] 3999934 iValueVek[9] 3999934 iValueVek[10] 0 Case B, BP set during execution gives, gives timer counting error: iValueVek[0] 960532 iValueVek[1] 3999934 iValueVek[2] 3999934 iValueVek[3] 3999934 iValueVek[4] 3999934 iValueVek[5] 3999934 iValueVek[6] 3992200 <-- WRONG Value (BP set in this time frame) iValueVek[7] 3999933 iValueVek[8] 3999933 iValueVek[9] 3999934 iValueVek[10] 0 So obviously setting a BP interactively (dynamically) during execution interferes with the Timer counting that leads to an erroneous result. In some way the setting of the BP temporary disables the counting for the timer. If this behavior is considered a bug or not can be debated. However it is good to know. For me it was rather confusing and I spent unnecessary time to figure it out. Regards, Bo, SM6FIE |
|
|
|
也许我应该补充一下,第一个值(IValueEvk〔0〕)不是一个错误值。它具有不同的值的原因很简单,因为它取决于在1个PPS周期中的哪个地方开始执行程序。/博城,SM6FIE
以上来自于百度翻译 以下为原文 Perhaps I should add that the first value (iValueVek[0]) is not an error value. The reason it has a different value is simple because it is depending on where in the 1 PPS cycle I start the execution of the program. /Bo, SM6FIE |
|
|
|
湿透了床,想到了问题,然后我突然意识到“NKurzman”终究会成为真正的“网络上的顶级枪手”。启动了我的开发系统,检查了我的项目选项。哎哟,在“冻结外设”下有一个选项取消定时器1,2,3,4,5。取消所有定时器的一个中提琴,现在它没有更多的定时器干扰时,动态设置BP。现在我知道了两件事。1)如何动态地(交互地)调试定时器和“NKurzman”确实是一个“PRO”。古德奈特,博城,SM6FIE。
以上来自于百度翻译 以下为原文 Wet to bed, thinking of the problem and then I suddenly realized that “NKurzman” eventually could be a real “Top Gun Pro on the Net”. Fired up my development system and did check my project options. Whoops, under “Freeze Peripherals” there is an options to deselect Timers 1,2,3,4,5. Deselected all timers an viola, now it works No more timer interference when dynamically setting BP. So now I know two things. 1) How too dynamically (interactively) debug timers and that “NKurzman” indeed is a “Pro”. Goodnight, Bo, SM6FIE |
|
|
|
只有小组成员才能发言,加入小组>>
5166 浏览 9 评论
2000 浏览 8 评论
1928 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3174 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2226 浏览 5 评论
734浏览 1评论
615浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
506浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
631浏览 0评论
528浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-24 15:50 , Processed in 1.358221 second(s), Total 86, Slave 70 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号