完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我用完了我的PIC24的内部RAM,认为我很聪明,把一些大的结构移到外部的SPI RAM芯片上。我编写了TythAuxRead Sub()和AuthOrthRead Enter()RAM驱动函数,它工作得很好。但是当我把指针指向这些结构到其他代码时,我得到XC16编译器错误,例如:“错误:从指针到非封闭地址空间的‘STLLN’传递参数1”。(已经编译的)SrLLN(CHAR*STR)的库代码不具有用于外部引用的胶粘代码。好的。但是,我是否需要对我当前的所有源代码进行新的版本,这样它也可以不包括外加指针?例如,MyStReGrimeCar(char * a,char *b)需要生成4种不同的调用签名来处理所有可能的场景:MyStRestCopReRe1(SuthalLax.char *a,char *b)MyStRePrimCARCAR2(char *a,yxAuthalLuxchar *b)MyStrugCoprRe3(SuthalAlxa char * a,yxEnthalLuxchar *b)MyStrugCoprRe4(char *)A、Char * B)有人建议我如何在不复制大量代码的情况下做到这一点?XC16能在后台自动地实现这一点吗?就像一个编译器选项:“自动生成方法在传递‘外外部指针’时的变体”,或者我可以声明这些函数是接受外部的指针,它们还会用正常的指针工作吗?也许会罚点球。
以上来自于百度翻译 以下为原文 I ran out of internal RAM of my PIC24 and thought I would be smart and move some large structures out to the external SPI RAM chips. I wrote the __read_external() and __write_external() ram driver functions and that works fine. But when I pass pointers to these structures to other code I get xc16 compiler errors such as: "error: passing argument 1 of 'strlen' from pointer to non-enclosed address space" I'm assuming it means that the (already compiled) library code for strlen(char* str) doesn't have the glue code to derference an external pointeral. Fine. But do I need to make new versions of the functions of all my current source code so it can also except __extern__ pointers? E.g myStringCompare(char* a, char* b) would need to make 4 different call signatures to handle all possible scenarios: myStringCompare1( __external__ char* a, char* b) myStringCompare2( char* a, __external__ char* b) myStringCompare3( __external__ char* a, __external__ char* b) myStringCompare4( char* a, char* b) Anyone has advice how I can do this without duplicating a lot of code? Could the xc16 make this automagically in the background? Like a compiler option: "Auto generate method variants when passing __external__ pointers" Or could I declare the functions as accepting __external__ pointers and they would still work also with normal pointers? Maybe with some speed penalty. |
|
相关推荐
5个回答
|
|
我会放弃2号,而保持1.4只能是2个场景。
以上来自于百度翻译 以下为原文 I'd drop number 2 and keep 1. 4 can just be strcmp That just leaves 2 scenarios. |
|
|
|
|
|
|
|
写一些包装纸。听起来好像你把它编得太多了。为什么你的内存用完了?你说你已经创建了很多函数。这些函数都叫吗?
以上来自于百度翻译 以下为原文 Write some wrappers. Sounds like you are over-compilcating it. Why are you running out of memory? You say you've created a lot of functions. Are all these functions called? |
|
|
|
我想到包装器,但不明白它们会是什么样子。}我还想到用预处理器魔术生成函数变体,但也不能想出一个解决方案。我猜链接器应该删除任何未使用的函数。而且,更多的功能只会影响闪光灯。我需要莫雷姆添加更多的功能。希望该项目最终将移动到一个更大的RAM平台。直到那时,我将乐意交换额外功能变量的闪存空间,以便能够透明地使用外部RAM。
以上来自于百度翻译 以下为原文 I thought of wrappers, but couldn't understand how they would look like. int strlen_wrapper( __external__ char* str){ ...?? } I also thought about generating the function variants with preprocessor magic but couldn't come up with a solution on that either. I'm guessing the linker should remove any unused functions? And still, more functions will only affect the flash. I need more RAM to add more functionality. Hopefully the project will move to a larger RAM platform eventually. Till then I would be happy to trade the flash space of the additional function variants for being able to use the external RAM transparently. |
|
|
|
链接器将在文件中加载,如果它有触摸。我会认为变化代码会很短,因为你已经做了外部RAM地面工作。
以上来自于百度翻译 以下为原文 The linker will load in the file if it has a touch. I would have thought the variation code would be short since you've done the external ram ground work. |
|
|
|
只有小组成员才能发言,加入小组>>
5237 浏览 9 评论
2027 浏览 8 评论
1950 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3202 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2253 浏览 5 评论
772浏览 1评论
662浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
590浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
672浏览 0评论
572浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-21 18:24 , Processed in 1.518755 second(s), Total 86, Slave 69 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号