完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛扫一扫,分享给好友
|
我正在使用PIC,程序在完成函数调用后返回到一个错误的行。然后发生异常(代码7,总线异常)。我尝试过调用堆栈并在每个函数调用之后检查“sp”CPU寄存器,但是十六进制返回到它应该的数字。顺便说一下,它不是中断函数,它只是在主循环中调用方法的一种方法。
以上来自于百度翻译 以下为原文 I'm using said PIC and the program returns to an incorrect line after finishing a function call.. then an exception (code 7, bus exception) happens. I've tried call stack and check the "sp" cpu register after every function call but the hex goes back to the number it should. By the way it's not an interrupt function, its just a method calling a method in the main loop. |
|
相关推荐
3个回答
|
|
|
您可能正在通过堆栈溢出或缓冲区溢出来破坏堆栈,或者CPU寄存器上出现了行为不当的ISR(例如,指定使用实际不使用的影子寄存器的ISR)。它也可能是编写代码写得很差,但你可能知道这一点。返回地址保存在$RA寄存器中。
以上来自于百度翻译 以下为原文 You're probably either trashing the stack via a stack overflow or a buffer overflow, or there's a badly behaving ISR stomping on the CPU registers (eg. an ISR specified to use shadow registers that actually doesn't). It could also be badly written assembly code, but you'd probably know about that. The return address is held in the $ra register. |
|
|
|
|
|
我已经解决了这个问题(谢谢爸爸),问题是我声明字符串的方式。我让编译器为我设置字符串大小,并且我执行了很多“strcat”调用,这些调用覆盖(实际上只是搞砸了)了一切……感谢andersm的帮助,但是正如我所说的,堆栈指针具有返回到调用函数时应该具有的值,并且有n在代码中的任何地方都是O ISR例程。无论如何谢谢!
以上来自于百度翻译 以下为原文 I've solved the problem (thanks Dad) The problem my way of declaring strings. i was letting the compiler set the string size for me and i was doing a lot of "strcat" calls, which was overwriting (and really just screwing up) everything.. Thanks for the help andersm, but as I said the stack pointer had the value it should when returning to the calling function, and there was no ISR routine anywhere in the code. Thanks anyways! |
|
|
|
|
|
这正好符合他提到的“缓冲溢出”的可能性。
以上来自于百度翻译 以下为原文 That fits precisely with the "buffer overflow" possibility he mentioned. |
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
473 浏览 0 评论
5793 浏览 9 评论
2334 浏览 8 评论
2224 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3530 浏览 3 评论
1124浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1097浏览 1评论
我是Microchip 的代理商,有PIC16F1829T-I/SS 技术问题可以咨询我,微信:A-chip-Ti
873浏览 1评论
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
475浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 07:27 , Processed in 1.084652 second(s), Total 76, Slave 59 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
865