1
完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,所有,我的团队一直在为PIC24FA32 KA304固件工作几个月。我们的程序内存用完了,买了一个XC16编译器许可证来优化代码,缩小了大小。我们发现除了“0”之外,任何优化设置都会在闪光灯(没有闪光灯等)的情况下使板成为砖块。优化“0”再次振兴董事会(所以我们知道它不会破坏硬件)。编译器优化固件功能有什么问题吗?(我使用编译器的MPLAB X IDE V3.51和V1.30)
以上来自于百度翻译 以下为原文 Hi all, My team has been working on a piece of firmware for the PIC24FA32KA304 for several months. We are running out of program memory, and bought a XC16 compiler license to optimize the code and bring the size down. What we find is that any optimization setting besides "0" bricks the board when we flash it (no flashing lights, etc). Optimizing with "0" again revives the board (so we know it doesn't destroy the hardware). Are there any known issues with the compiler optimizing out firmware functionality? (I'm using MPLAB X IDE v3.51 and v1.30 of the compiler) |
|
相关推荐
8个回答
|
|
优化更改代码行为通常表示代码中的错误。请特别注意:从中断和非中断代码中访问的变量。如果ISR写入这些变量,则必须标记为“易失性”。当指针不再在范围内时,通过指针访问缓冲区。用户创建。D时间延迟。使用编译器提供的γ-DelayyMsor(或)
以上来自于百度翻译 以下为原文 Optimisation changing code behaviour usually indicates bugs in your code. Pay particular attention to: Variables accessed both from interrupt, and non-interrupt code. These MUST be marked as "volatile" if written to by the ISR. Accessing buffers via pointers when they are no longer in scope. User created time delays. Use the compiler supplied __delay_ms() or __delay_us() macros instead. |
|
|
|
通常情况下,这是因为你的代码中有一些bug,优化显示出来…
以上来自于百度翻译 以下为原文 Mmmm usually when this happens, it's because there was some bug in your code that optimization make show out... |
|
|
|
或者你的代码中显示的编译器中的一个bug。
以上来自于百度翻译 以下为原文 Or a bug in the compiler which your code reveals. It's either this or that :) |
|
|
|
不管怎样,是时候做一些法医调试,检查你的代码被卡在哪里了。
以上来自于百度翻译 以下为原文 Either way, it's time to do some forensic debugging, and check where your code is getting stuck. |
|
|
|
也有初始化变量的可能性。优化可以更频繁地重用内存空间。你将需要调试更多的代码比寻找灯闪烁。如果它是一个优化的bug,你将需要通过调试来跟踪它。这些bug往往与一个非常特定的代码序列有关。
以上来自于百度翻译 以下为原文 There is also the possibility of initialized variables. Optimization may reuse memory space more often. You are going to need to debug the code more than looking for the lights to blink. If it is an optimization bug you will need to track it down by debugging anyway. These bugs tend be related to a very specific code sequence. |
|
|
|
谢谢大家的建议!我做了一些调试,没有找到。我试着改变在中断中使用的一些挥发物,这就是罪魁祸首。非常感谢您的输入!
以上来自于百度翻译 以下为原文 Thank you all for your suggestions!! I did some debugging and got no where. I tried out changing some volatiles used in interrupts, and that was the culprit. Thanks so much for your input! |
|
|
|
仔细检查你的变量用法,确保所有的变量都被写入到ISR内部,并在ISR外部读取,这些变量必须标记为易失性,而且,即使标记为易失性,任何大于16比特的变量都必须得到很好的处理。ULY,因为它需要多个机器指令读取超过16位,而中断可以改变中间值。
以上来自于百度翻译 以下为原文 So it WAS a bug. Carefully check your variable use to make sure you got them all. As mentioned, any global variable which is written to inside an ISR, and read outside the ISR, must be marked as volatile. Also, even marked as volatile, any such variable larger than 16 bits has to be treated very carefully, as it takes multiple machine instructions to read more than 16 bits, and an interrupt could change the value in the middle of that. |
|
|
|
嗨,完全同意。实际上,这是测试软件的好方法。
以上来自于百度翻译 以下为原文 Hi, Fully agree. Actually this is a good way to test software ;=) Regards |
|
|
|
只有小组成员才能发言,加入小组>>
5255 浏览 9 评论
2038 浏览 8 评论
1958 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3219 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2268 浏览 5 评论
794浏览 1评论
689浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
618浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
687浏览 0评论
587浏览 0评论
小黑屋| 手机版| Archiver| 德赢Vwin官网 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-30 20:04 , Processed in 1.651879 second(s), Total 89, Slave 74 queries .
Powered by 德赢Vwin官网 网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
德赢Vwin官网 观察
版权所有 © 湖南华秋数字科技有限公司
德赢Vwin官网 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号