完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我在PIC24FJ256GB108上有一大块代码。我有USB主机、以太网和MIWI。有时XC16的编译器版本将不工作,但其他人会,然后我改变我的代码相反的是真实的。示例1.26我的程序挂起,但1.30工作。更改我的代码,然后1.30挂起和1.25工作。我遇到过不能正确使用外部环境的问题,并且遇到过全局变量的问题。我看到其他代码使用包和对齐。TyPulfUnion AyAtditTyx((对齐(2),填充”)什么时候使用这些?有没有办法在一些微妙的问题上提出更多的警告?
以上来自于百度翻译 以下为原文 I have a large bit of code on the PIC24FJ256GB108. I have USB host, Ethernet, and MiWi. Sometime a compiler version of the xc16 will not work but others will, then I change my code the the opposite was true. Example 1.26 my program hangs, but 1.30 works. Change my code then 1.30 hangs and 1.25 works. I have had issues with not using externs correctly and have had issues with global variables. I see other code using pack and aligned. typedef union __attribute__((aligned(2), packed)) When should these be used? Is there a way to turn on more warnings for some subtle issue? |
|
相关推荐
5个回答
|
|
确实超出了我的专业范围,但是我并不期望对齐(也可能是打包)属性在应用于typedef时能够工作。您并没有真正告诉我们出什么问题——说程序“挂起”并没有真正帮助。调试器,当你认为它已经挂起时强制中断?你为什么在编译器之间切换?为什么不弄清楚你正在使用的构建环境有什么不对呢?你改变的机会越少,你找到解决问题的机会就越少。苏珊
以上来自于百度翻译 以下为原文 Really going outside my area of expertise here but I would not expect the aligned (and possibly the packed) attribute(s) to work when they are applied to a typedef. You have not really told us what is going wrong - saying the program is 'hanging' does not really help. Have you tried running under the debugger and forcing a break when you think it has hung? Why are you switching between compilers? Why not work out what is wrong with the build environment you are using? The more you change the less chance you will have of finding the solution. Susan |
|
|
|
我想调试我正在编写的代码,而不是一些微妙的东西,可能需要数天才能发现。我的问题似乎是中断导致地址错误的问题。程序中有异常处理程序(陷阱)吗?这将导致问题以及问题发生的位置。地址错误可能是一个错误的指针,或者堆栈溢出。Packd告诉编译器不要将虚字节放入结构(保持它们16位对齐)中,而2告诉编译器将从16位地址开始的变量放入这个入口。例如,如果您有一个字节数组,有时需要使用int指针来设置。这种类型的问题可能会很好,因为编译器可以找到变量,甚至地址偶然。改变任何事物都会导致它消失。
以上来自于百度翻译 以下为原文 I want to debug the code I am writing and not some subtle thing that could take days to discover. My issues seems to be an issue with interrupts causing an addresses error. DO you have the exception Handler (Traps) in the Program. That will get you the issue and Where it is happening. Address error could be a bad pointer, or you overflowed the stack. Packed tells the compiler not to put dummy bytes in structs (to keep them 16 bit aligned) alligned 2 tells the compiler to put the variable starting at 16bit address this is inportand if for example you have a byte array that you sometimes whay to set using an int pointer. This type of issue can come and good since the compiler may locate the variable on and even address by chance. and changing anything can cause it to nove. |
|
|
|
我有陷阱,我不能一直运行调试器。当我在我的MiWi网络上的其他设备上用调试器测试一个特性时,它会随机地挂起。我必须停下来看看主设备是否挂断,或者如果我的代码有问题,我正在调试。我使用指针,但我认为它们是安全的。我将仔细观察它,并可能对齐和包装/垫结构可能需要它。
以上来自于百度翻译 以下为原文 I have traps, I just can't run the debugger all time. It hangs randomly when I am testing a features with my debugger on the other devices in my MiWi network. I always have to stop and see if the main device is hung up or if I have a problem with my code I am debugging. I use pointers but I think they are safe. I will look at it closely and maybe align and pack/pad structs that might need it. |
|
|
|
谢谢包装和对齐的定义。我看到我的一些结构/工会可以使用一些填充和对齐。对我来说也没什么意义。只是我不能复制它,而且看起来是随机的。我正在调试我的无线网络中的另一个处理器。因此,在我的主要无线节点上的陷阱不会神奇地停止我调试的设备在3FT之外的调试器。我可以停止我的编码进度,试着看看哪里和为什么。记住它是随机的,所以有时候它每10分钟或每周一次。但是步骤2是什么呢?我有一种直觉,这就是地址陷阱,因为它总是地址陷阱。好的编码实践和编译理解有很大帮助。我希望编译器会告诉我,我是愚蠢的。垃圾是垃圾。因此,我正在研究增加我对编译器和PIC24F系列控制器的知识。为什么编译器版本会导致运行时问题。
以上来自于百度翻译 以下为原文 Thank you for the defining of packed and aligned. I see that some of my structures/unions could use some padding and aligning. Means little to me too. It's just that I can't reproduce it, and it seems random. I am debugging another processor in my wireless network. So a trap on my main wireless node will not magically stop my debugger on the device I am debugging 3ft away. I could stop my coding progress and try to see the where and why. Remember it is random so sometimes it shows up every 10 minutes or once a week. But what is step 2. I have a gut feeling it is address trap, because it is always address trap. Good coding practices and compiler understanding goes a long way. I hoped the compiler would tell me that I am being stupid. Garbage in is garbage out. So I am looking at increasing my knowledge of the compiler, and PIC24F series controllers. Also why compiler versions would cause run time issues. |
|
|
|
您可以在编译器上提升警告级别。海湾合作委员会让我们大量违约。你可以买PC-LIT来得到更多的警告。所以悬挂你意味着停止和另一个处理器对话。它可以是几十件东西。一个更好的程序员的一部分是学习如何调试。你需要知道在这种情况下,你的硬件。我不知道人们给你提供的信息有多大帮助。
以上来自于百度翻译 以下为原文 You can jack up the warning level on the compiler. GCC let's a lot go by default. You could buy PC-LINT to get even more warnings. So by hang you means stops talking to the other processor. It can be dozens of thing. Part of being in a better programmer is learning How to debug. You are going to need to figure out how in this case,which your hardware. I am not sure how much help people can give you with the information you have provided. |
|
|
|
只有小组成员才能发言,加入小组>>
5171 浏览 9 评论
2001 浏览 8 评论
1931 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3176 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2228 浏览 5 评论
737浏览 1评论
622浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
509浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
635浏览 0评论
533浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-26 05:18 , Processed in 1.338008 second(s), Total 86, Slave 69 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号