完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨!我使用PIC16F1824并在使用延迟函数时在调试模式中遇到一些奇怪的情况。这是如何设置延迟函数:在调试模式下,当程序流处于延迟函数(附件1)时,我单击“步骤”以执行下一行,但程序流仅停留在延迟STA中。我还没有完成它(附件2),我点击了“暂停”,看看程序流现在在哪里,但是它仍然在延迟函数中。我能完成延迟功能的唯一方法是:1。在下一站设置BP。点击“继续”这个现象正常吗?谢谢!
以上来自于百度翻译 以下为原文 Hi, there! I'm using the PIC16F1824 and run into some weird situation in the debugging mode when using delay function. This is how I set delay function: #define _XTAL_FREQ 4000000 // the frequency of device is 4M hz __delay_ms(1000); //function call to delay function by 1 second delay In debugging mode, when program flow is at delay function(attachment 1) I clicked "Step over" to execute next line, but the program flow just stuck in delay statement and never finished it(attachment 2) I clicked "Pause" to see where is the program flow now, but it is still at the delay function. The only way I can finish delay function is: 1. set bp at next line 2. click "Continue" bottun Is this phenomenon normal? Thanks! Attached Image(s) |
|
相关推荐
12个回答
|
|
可能是因为这不是一个函数。它是一个宏。如果不想设置断点,可以尝试将光标设置为下一行,并使用“Run to Curror”。
以上来自于百度翻译 以下为原文 May be it's because this is not a function. It's a macro. If you do not want to set a breakpoint, you could try to set the cursor to the next line and use "run to cursor" |
|
|
|
VoLoKi:这是Ay-DelayyMs()MARCO:这可能是O-DELAY()函数吗?我不知道延迟是一个函数还是一个函数,但是…这就是程序流不能完成这一行的原因吗?
以上来自于百度翻译 以下为原文 To vloki: This is the __delay_ms() marco: #define __delay_ms(x) _delay((unsigned long)((x)*(_XTAL_FREQ/4000.0))) and this is the_delay() function maybe? extern __nonreentrant void _delay(unsigned long); I don't see whether the delay is a function or a marco. but....is this the reason that program flow can't finish this line? |
|
|
|
|
|
|
|
基本上编译器将ASM等效为嵌套的for循环。它根据时间和xTalthFrq计算循环数。
以上来自于百度翻译 以下为原文 Basically the compiler puts the ASM equivalent of a nested for loop there. It calculates the number of loops based on the time and XTAL_FREQ |
|
|
|
Tovloki:我的意思是:我确信Syth-DelaysMy()是一个宏,但是在这两行中,很明显地看到了γ-DelayySMS()MARCO使用的是O-DELAY()函数,这使我感到困惑。BTW,我检查了编译器指南,没有说明。谢谢:
以上来自于百度翻译 以下为原文 To vloki: What I meant is: I'm sure that the __delay_ms() is a macro, but in this two line: #define __delay_ms(x) _delay((unsigned long)((x)*(_XTAL_FREQ/4000.0))) extern __nonreentrant void _delay(unsigned long); it's clear to see that the __delay_ms() marco uses _delay() function, that's confusing me. BTW, I did check the compiler guide, there is no explanation of it. Thank you :) |
|
|
|
Delay计算请求的延迟周期数。编译器为此生成代码。
以上来自于百度翻译 以下为原文 Delay counts the requested number of delay cycles. The compiler generates the code for that. |
|
|
|
ToNKurzman:谢谢,我决定阅读列表文件,看看发生了什么事,导致程序流滞留在延迟函数中,并且永远不会在调试会话中退出。
以上来自于百度翻译 以下为原文 To NKurzman: Thank you, I decide to read listing file to see what happened resulting in program flow stuck in the delay function and never went out in the debugging session. |
|
|
|
步进执行一个被调用的子程序(函数),并在调用指令后的地址停止。它扩展成一个嵌套循环指令来消耗周期。由于这两个都不是真正的函数,所以没有执行STEP的调用指令。或者您也可以查看它,因为没有执行步骤的返回指令。;)
以上来自于百度翻译 以下为原文 The Step Over executes a called subroutine (function) and halts at the address following the CALL instruction. The __delay_ms() is a macro (pseudo function) that consumes the specified time by calculating the number of cycles required for that time based on _XTAL_FREQ, and it uses the _delay() macro that expands into a nested loop of instructions to consume cycles. Since both are NOT real functions, there is no CALL instruction for Step Over to execute. Or you can also look at it as there is no RETURN instruction for Step Over to execute to. ;) |
|
|
|
|
|
|
|
嗨,也许你不能一步一步地做,因为宏使用一个源代码不可用的库。只要在下一个C指令上设置一个断点,然后推执行。之后你可以恢复到一步一步。
以上来自于百度翻译 以下为原文 Hi, Probably you cannot do step by step as the macro uses a library which source code is not available. Just put a breakpoint on the next C instruction and push execute. After you can resume to step by step. Regards |
|
|
|
????尝试检查图书馆附录。它也在索引中提到,当然可以搜索PDF。在头文件中,您会注意到与标识符关联的内在语法,而用户指南告诉您,它是一个由代码生成器扩展的“内联函数”。因此,它不是一个调用,并且IDE阶跃函数在执行这样的代码时可能不完全符合预期。
以上来自于百度翻译 以下为原文 ??? Try checking the Library Appendix. It's also mentioned in the index, and you can of course search the PDF. You will notice in the header file that there is an intrinsic pragma associated with that identifier, and the User's Guide tells you that the it is an 'in line function that is expanded by the code generator '. So, it's not a call, and it is possible that the IDE step function does not behave exactly as expected when executing such code. Jeff. |
|
|
|
我认为这是一个带有MPLAIDE的bug。我只是在MPLAB8中模拟了α-DelayyMs-()。在A*-DelayyMs(1)上跨过步骤,在下一个语句中停止,但对于Y-Y-DelaysMs(2)和更长的延迟,我必须永远杀死IDE才能恢复。
以上来自于百度翻译 以下为原文 I think this is a bug with the MPLAB IDE. I just simulated __delay_ms() in MPLAB8. Step Over steps over __delay_ms(1) and stops at the next statement, but it takes forever for __delay_ms(2) and longer delays that I have to kill the IDE to recover. |
|
|
|
只有小组成员才能发言,加入小组>>
5291 浏览 9 评论
2059 浏览 8 评论
1969 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3233 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2277 浏览 5 评论
824浏览 1评论
710浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
654浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
710浏览 0评论
609浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-1-15 00:58 , Processed in 1.359159 second(s), Total 99, Slave 83 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (威廉希尔官方网站 图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号