完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
嗨,AllI试着把一些初始化数据放在PIC16F18366上的EEPROM上,使用的是Y-EEPROMYDATA宏。编译器运行宏时没有抱怨,但是当我查看编译器输出时,我注意到它使用的是EEPROM的3倍。仔细检查,使用内存视图窗口,揭示了宏正在把三个背靠背的输入数据拷贝到EEPROM中。例如,如果我把EEPROM装入2,3,4,5,6,7,8,1,2,3,4,5,5,γ,α,α,α,α,α,α,α,α,α,α,α,α,α,α,α,α,α,α,α,α,α,β,β,4,5,5,5,5,5,5,γ,α,α,α,α,α,α,α,α,α,β,β,4,5,5,5,5,5,5,5,γ,α,α,α,α,α,α,α,α,α,α,β,β,4,5,5,5,5,5,5,5,γ,α,α,α,α,α,α,α,α,α,α,β,β,4,5,5,5,5,5,5,5,π,γ,我打算在代码完成的时候使用超过50%的EEPROM,所以如果我找不到治疗方法,我将在不久的将来开始遇到问题。我试着用下面的方法,但是编译器不高兴,一直抱怨重新定义“DE”,它似乎不值得去做。NG来找出原因。我在更多的设备上使用了Y.EEPROMPEDATA宏,因为我喜欢我的代码是可移植的,因为对于我来说,由于外部的影响,我不能把我的代码移植到一个不同的设备上。
以上来自于百度翻译 以下为原文 Hi All I'm attempting to place some initialisation data into the EEPROM on a PIC16F18346 using the __EEPROM_DATA macro. The compiler is running the macro without complaint but when I looked at the compiler output I noticed that it'd used 3 times the amount of EEPROM I was intending. Closer inspection, using the memory views windows, has revealed that the macro is placing three back to back copies of the input data into the EEPROM. So for instance if I called __EEPROM_DATA (1, 2, 3, 4, 5, 6, 7, 8) __EEPROM_DATA (9, 10, 11, 12, 13, 14, 15, 16) the EEPROM would be filled with 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 9 10 11 12 13 14 15 16 9 10 11 12 13 14 15 16 does anybody know what's going wrong or how I could get round this? I'm intending upon using over 50% of the EEPROM by the time the code is finished so I'm going to start running into problems in the near future if I don't find a cure. I tried using the following asm("torgt0x7000"); asm("tdet1, 2, 3, 4, 5, 6, 7, 8"); but the compiler wasn't happy, kept complaining about redefinition of "de", and it didn't seem worth trying to find out why. I'm using the __EEPROM_DATA macro over the more device specific ones as I like my code to be portable because it isn't unknown for me to end up porting my code to a different device due to external influences. Thanks Russell |
|
相关推荐
4个回答
|
|
|
没有看到实际的源代码和项目设置和生成的文件,我们可以作出很少的结论性声明任何此类问题。发布一个短的、自包含的、正确的例子,我们可以构建它来重现症状。但是我猜你有一个头文件中的宏,它被包含在一个以上的源文件中。
以上来自于百度翻译 以下为原文 Without seeing the actual source code and project settings and generated files we can make very few conclusive statements about any such issue. Post a Short, Self Contained, Correct Example that we can build to reproduce the symptom. But my guess is that you have the macro in a header file that is being included in more than one source file. |
|
|
|
|
|
嗯,使用XC8版本1.41,当我把这些语句放在我的测试板上(在分号之后),EEPROM的前16个字节是1、2、3、4、5、6、7、8、9、10、9、16、16个水晶球今天有点雾,但我的猜测和马克的一样。戴夫,问候。
以上来自于百度翻译 以下为原文 Well, using XC8 version 1.41, when I put those statements in a test program (after putting semicolons at the ends) on my breadboard, the first 16 bytes of EEPROM are 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Crystal ball is a little foggy today, but my guess is the same as Mark's. Regards, Dave |
|
|
|
|
|
谢谢你,Goest.可悲的是,代码在我的工作电脑上,无法上传。由于您的答复,我已经在家里玩了一个尽可能接近相同的设置,我没有遇到问题。安装:-MPLAB x3.5xC81.4Win 7 64项目使用所有默认设置ICD 3程序员选择。宏是,如你所说,在头文件是CALED来自多个地点。但是我已经使用了μIFNDEF语句来保护它(无论如何都是在MPLAB中是标准的),所以我假设这些阻止了宏被多次调用。我猜不是这样的吧?可悲的是,我现在离开办公室一点,所以我不能玩,但我可以把它们移动到主文件,所以他们只分析了一次(但我宁愿不由于公司编码标准)。是否有一种方法来保护它们在头文件中,如果α?IFNDEF语句不执行任务?
以上来自于百度翻译 以下为原文 Thanks gents. Sadly the code is on my work computer so can't be uploaded. Since your replies I've had a play around at home using as close to the same setup as possible and I didn't run into the problem. Setup: - MPLAB X 3.5 XC8 1.4 Win 7 64 project created using the all default settings ICD 3 programmer selected. The macros are, as you say, within a header file which is called from multiple locations. But I have protected it using #ifndef statements (as is standard within MPLAB anyway) so I would have assumed that these prevented the macros being called multiple times. I'm guessing that this isn't the case? Sadly I'm now out of the office for a bit so I won't be able to play around, but I could move them into the main file so they are only parsed once (but I'd prefer not to due to company coding standards). Is there a way to protect them within the header file if the #ifndef statements aren't doing the job? |
|
|
|
|
|
宏不被称为“包含保护”,只是在每个编译单元中阻止它们被多次包含,但是如果您有多个C文件,它们都包含它们,那么它们在链接之后在您的最终程序上出现多次。参见:在C和C++中组织代码文件(忽略C++特定的)。位)
以上来自于百度翻译 以下为原文 Macros are not called. include guards just stop them being included more than once in each compilation unit, but if you have multiple C file which all include them, then they ARE present multiple times on your final program after linking. See:
|
|
|
|
|
只有小组成员才能发言,加入小组>>
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:44 , Processed in 0.910402 second(s), Total 47, Slave 40 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
1407