完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我面对这个数组初始化问题与PIC18F47 K40。在初始化数组时,使用赋值likeunsigned int.[]={0,1,101001000};//在watch和可变窗口中调试时看到的所有取0x0000的数组元素的值。如果赋值likeunsigned int.[0]=0;unsigned int.[1]=1;unsigned int.[2]=10;数组[3]=100;无符号整数组[4]=1000;它工作正常,但我需要初始化数组,因为我在应用程序中使用指向字符数组的指针。但是相同的代码正在使用PIC18f46k80、PIC18F4620和PIC18f46k22,我试过。如果需要任何帮助,请附上我的代码。我试着用全局,静态和const,但没有运气。
以上来自于百度翻译 以下为原文 I am facing this array initialization issue with PIC18F47k40. When i am initializing array with assigning values like unsigned int array[] = {0,1,10,100,1000}; //All the values of array elements taking 0x0000 I saw with debug in watch and variable window. If i assign like unsigned int array[0] = 0; unsigned int array[1] = 1; unsigned int array[2] = 10; unsigned int array[3] = 100; unsigned int array[4] = 1000; its working fine, but i need the array with initialization because i am using pointer to character array in my application. But same code is working with PIC18f46k80, PIC18F4620 and PIC18f46k22 i tried. I am attaching my code please if any help possible do the needfull. I tried with global, static and const also but no luck. |
|
相关推荐
9个回答
|
|
你的MPLAB X IDE版本是什么?我刚在V3.50上试用过,看起来不错。
以上来自于百度翻译 以下为原文 what's your MPLAB X IDE version? I just tried it on v3.50, it looks OK. |
|
|
|
如果您的代码还没有实际使用数据,那么这证明不了什么。优化编译器可以随意丢弃任何没有用处的代码。
以上来自于百度翻译 以下为原文 This proves nothing if your code doesn't actually USE the data yet. Optimising compilers are free to throw away any code which doesn't do anything useful. |
|
|
|
我也使用相同的MPLABX V3.50。我的代码是工作的还是你做的任何改变?像头文件还是不同的初始化?
以上来自于百度翻译 以下为原文 I am also using same MPLabX v3.50. Is my same code is working or any changes you have done? like header files or different initialisation? |
|
|
|
只是很简单,编译器是XC8 1.38。
以上来自于百度翻译 以下为原文 just very simple, #include unsigned int array[] = {0,1,10,100,1000}; void main() { array[0]=1; while(1){} } compiler is XC8 1.38. |
|
|
|
试试这个
以上来自于百度翻译 以下为原文 Try this #include unsigned int array[] = {0,1,10,100,1000}; void main() { array[0]=1; { volatile int dummy; unsigned char idx; for (idx=0; idx < 5; idx++) dummy = array[idx]; //this will always be done because dummy is "volatile" } while(1){} } |
|
|
|
对于‘K40系列’中的所有芯片,有一个重要的差错。对于XC8版本1.38,您需要Errata文档DS80000712BThat的第3.1节中所示的解决方法:在项目中创建一个新文件,powerup.as。(但是:请参阅下面的编辑信息。)以下是我放入该文件的内容:如果没有此修复,全局初始化将无法工作,并且许多其他内容将无法工作。(任何访问程序内存中的数据的东西,比如printf(),例如)Note:[/Begin Edit]Release notes for XC8 version 1.40表明以下内容应该修复它,但是对我不起作用:向项目Properties->XC8 Global Options->XC8编译添加以下命令行选项r->Additional Options行--ERRATA=NVMREGSo,我仍然使用如Errata中所示的powerup.作为修复,甚至对于XC8版本1.40。使用XC8版本1.40和以后版本进行修复的正确方法是:在Project Properties XC8全局选项->XC8 Linker->AdditionalOption选项中输入+nvmreg也就是说,它是一个链接器选项,而不是编译器选项。(哈扎!)最后,Errata文档指出硅修订版A4不需要,但是我没有任何这样的芯片要测试。两者都处于“自由”模式。注意,除了裸金属硬件和软件之外,我没有使用模拟器、调试器或其他任何工具进行测试:使用printf()验证内存内容和其他功能的、以全速生产发行版运行的真实芯片。
以上来自于百度翻译 以下为原文 There is an important erratum for all chips in the 'K40 family. With XC8 version 1.38, you need the workaround shown in Section 3.1 of the Errata document DS80000712B That is: Create a new file, powerup.as, in your project. (But: See edited information below.) Here's what I put in that file: ; ; ; From Errata document DS80000712B for the PIC168F27K40 ; ; From davekw7x: This workaround is still necessary ; as of XC8 version 1.40 (December 14, 2016) ; #include global powerup,start psect powerup,class=CODE,delta=1,reloc=2 powerup: bsf NVMCON1, 7; From errata document DS80000712B goto start end Without this fix, global initialization won't work, and a lot of other stuff won't work. (Anything that accesses data in program memory, like printf(), for example) Note: [/Begin Edit] Release notes for XC8 version 1.40 indicate that the following should fix it, but it didn't work for me: The proper way to do it with XC8 version 1.40 and later is the following:
Bottom line: With recent compiler versions you don't need powerup.as any more. (Huzzah!) [/End Edit] Finally, The Errata document indicates that is not necessary for silicon revision A4, but I don't have any such chips to test. Bottom line: Tested on my MPLABX version 3.50 PIC18F27K40 project with XC8 version 1.38 and version 1.40. Both in "Free" mode. Note that I did not test with simulator or debugger or anything other than bare-metal hardware and software: Real chip running with production release at full speed, using printf() to verify memory contents and other functionality. Regards, Dave |
|
|
|
最近出现的:HTTP://www. McCHIP.COM/FUMMS/FUNDSPE/96223
以上来自于百度翻译 以下为原文 That comes up recently: http://www.microchip.com/forums/FindPost/964223 |
|
|
|
请您共享PIC18F47 K40初始化的源代码。
以上来自于百度翻译 以下为原文 Please can you share your source code for initialization of PIC18F47K40. |
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
5238 浏览 9 评论
2028 浏览 8 评论
1950 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3204 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2253 浏览 5 评论
778浏览 1评论
666浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
595浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
677浏览 0评论
576浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-23 06:48 , Processed in 1.391337 second(s), Total 62, Slave 56 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号