完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我想在PIC32MX170256B提供的闪存程序空间中定义一个应用程序定义内存区域。在帮助文档中使用MPLAB X IDE v3.45的帮助文档中的XC32工具链的MPLLABXC32C编译器部分中的内存分配和访问下,我使用“应用程序定义内存区域”跟踪文档。代码使用:#pragma区域名称=“Config”origin=0x9D03C000size=0x4000I,我试图更改上面的起源和大小。更改它们不会改变行为。区域中的每个变量都具有以下属性:u.((.("Config"))代码编译和链接良好,没有任何错误或警告。但是,C运行时初始化代码在调用main之前得到一个一般的异常。我有一个真正的冰,并且可以在执行程序时通过汇编程序。代码似乎在引导加载程序内存的某个地方出现故障,但是在没有访问实际汇编程序(或C源代码?)如果我从配置区域变量中删除“.”属性,则运行时C初始化代码执行得很好,调用main。有人成功地使用“.”属性定义CPU提供的程序空间的区域吗?可能是“区域”属性不能应用于CPU提供的程序空间。文档中的描述和示例表明了这一点,而“--.-mem”的使用显示了“Config”区域作为外部存储器。如果是这样,这是如何实现的?我意识到我可能需要编写一个定制的链接器脚本,但是region属性是用更低的支持成本实现相同目标的一种相当优雅的方式。
以上来自于百度翻译 以下为原文 I would like to define an Application Defined Memory Region in the flash program space provided by the PIC32MX170256B. The core idea is to carve out a fixed area of the 256K program space for a factory defined configuration that will (possibly) be later updated by customer defined configuration information. I followed the doc using "Application Defined Memory Regions" under Memory Allocation and Access in the MPLAB XC32 C Compiler section of the XC32 Toolchain in the Help docs using MPLAB X IDE v3.45. The code uses: #pragma region name="Config" origin=0x9D03C000 size=0x4000 I have tried changing the origin above and the size. Changing them does not change the behavior. Each of the variables in the region have the following attribute: __attribute__((region("Config"))) The code compiles and links nicely without errors or warnings of any kind. However, the C runtime initialization code gets a general exception before main is called. I have a real-ice and can step through the assembler as it executes. The code appears to be failing somewhere in the boot loader program memory but it is a bit difficult to deduce what is going on without access to the actual assembler (or C source?). If I remove the "region" attribute from the configuration area variables the runtime C initialization code executes nicely and main is called. Has anyone had success using the "region" attribute to define regions of CPU provided program space? It may be that the "region" attribute cannot be applied to CPU provided program space. The description and example in the docs suggest this and the use of "--report-mem" shows the "Config" region as external memory. In summary, Can the "region" attribute be used to define regions of CPU provided program space? If so, how is this accomplished? I realize that I may have to write a custom linker script; but the region attribute is a rather elegant way to accomplish the same objective with a much lower support cost. I would appreciate any insight or suggestions you may have on this topic. |
|
相关推荐
3个回答
|
|
嗨,我对你的主要问题没有答案,但是:汇编程序启动代码的源代码可以在xc32编译器安装中获得:……程序文件(x86)>微芯片>xc32>v1.42>pic32-libs>libpic32>startup>crt0.S可以将文件复制到自己的源目录中,并在IDE项目中引入。通用异常处理程序的源在同一目录中可用。
以上来自于百度翻译 以下为原文 Hi, I do not have an answer for your main question, but: Source code for the assembler startup code is available with the xc32 compiler installation: ... program files (x86) > microchip > xc32 > v1.42 > pic32-libs > libpic32 > startup > crt0.S You may copy the file into your own source directory and introduce in your IDE project. Also source for the general exception handler is available in the same directory. Regards, Mysil |
|
|
|
您可以只使用AyAtAtditType来定位闪存地址中的数组或结构,并使其占据整个页面。
以上来自于百度翻译 以下为原文 you could just use __attribute__ to locate an array or struct at a flash address and make it take up a full page, to pages. |
|
|
|
多亏了MySil和NKurzman的洞察力,他们才真正帮助我明白了发生了什么。结果证明,区域属性似乎可用于为特殊目的定义程序空间内存。你必须确保不与其他内存空间发生冲突,当然,这是我正在做的。XC32链接器为._mem保留PIC32MX170256B的顶部4K,因此您的区域不能覆盖这一个。通过调整语用以在._mem之前结束其区域定义,初始化异常不会发生。而且,我依赖于这样一个事实,即程序内存空间kseg0_._mem从低内存地址填充到高内存地址,并且其内容没有扩展到0x3B000(236K)以上。#pragma区域名称=“Config”origin=0x9D03B000size=0x4000,所以这里给出的教训是:32区域属性,您需要知道XC32(版本1.42)中的“区域”属性对应于链接器MEMORY区域。在定义一个区域时,您需要了解占用程序内存的其他区域的来源和大小,以便可以规划良性的重叠。这个映射在编译器位置>/pic32mx/lib/proc/<.>/<.>.ld中。我的例子是:C:/Program Files(x86)/Micro./xc32/v1.42/pic32mx/lib/proc/32MX170F256B/p32MX170F256B。
以上来自于百度翻译 以下为原文 Thanks to MySil and NKurzman for your insight they really helped me understand what was going on. It turns out that the region attribute appears to be usable to define program space memory for special purposes. You just have to be sure not to conflict with other memory spaces, which, of course, I was doing. The XC32-linker reserves the top 4K of the PIC32MX170256B for exception_mem; so your region must not overwrite this one. By adjusting the pragma to end its region definition before exception_mem an initialization exception does not occur. Also, I'm relying on the fact that the program memory space, kseg0_program_mem, is filled from low memory address to high memory address and that its content does not extend above 0x3B000 (236K). #pragma region name="Config" origin=0x9D03B000 size=0x4000 So it appears the lesson here is: If you use XC32 region attribute you need to know that the "region" attribute in XC32 (version 1.42) corresponds to the linker MEMORY regions. When defining a region, you need to understand the origin and size of the other regions that occupy the program memory so you can plan benign overlap. This map is in in the compiler location. In my case it is: C:/Program Files (x86)/Microchip/xc32/v1.42/pic32mx/lib/proc/32MX170F256B/p32MX170F256B.ld I hope this helps others to avoid this problem. /B |
|
|
|
只有小组成员才能发言,加入小组>>
5160 浏览 9 评论
1998 浏览 8 评论
1927 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3170 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2225 浏览 5 评论
731浏览 1评论
613浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
503浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
629浏览 0评论
527浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 17:15 , Processed in 1.333262 second(s), Total 83, Slave 66 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号