让我澄清一下:我检查了几种在Flash中声明缓冲区的方法:1。const无符号int MyFlash内存[32 ]={1,2,3,4,5,6,7,8};2。const无符号int yAtAtditTyx((地址(0x15000)))MyFlash存储器[32 ]={1,2,3,4,5,6,7,8};3。const无符号int yAtAtditTyx((空间(PSV),地址(0x15000)))MyFlash存储器[32 ]={1,2,3,4,5,6,7,8};4。const无符号int yAtAtditTyx((空间(PROG),地址(0x15000)))MyFlash存储器[32 ]={1,2,3,4,5,6,7,8};5。(32)[1,2,3,4,5,6,7,8};6。(32){ 1,2,3,4,5,6,7,8};一些定义引起麻烦。(使用本测试的模拟器)1。编译器将常数放置在名为“.const”(在我的例子位于0x000 0300)的LoWordDebug [K]=MyFlash内存[k}的区段中,代码是OK的。编译器将DSRPAG设置在不可见代码中的任何地方到0x0200,并用MOV[W0]读取MyFlash空间的第一个字。W0=0x8300,即偏移0x0300和比特15设置为指示PSV/EDS访问。2。一个地址是放置常量的地方。在这种情况下,编译器生成警告:MyFlash内存不被放置到编译器管理的PSV部分(由于地址());假设空间(PSV)为“MyFlash内存”。常量放置在地址为0x15000的Flash中,代码类似于1。但是DSRPAG被设置为0x001而不是0x0202。(0x00万…0x07FFF-&;DSPPAGG=0x200;0x00 8000…0x00 FFFF & &;DSPPAG=0x0201;0x010000…0x017FFF & &;dSPPAG=0x0202),因此结果是错误的,有时运行此代码模拟器崩溃(没有单步执行,没有重置,没有完成调试会话可能)。重新启动MPLAB X(V3.45)需要3.3显式使用空间(PSV):没有警告,没有错误,常量放置在闪存在0x15000。同样的问题和2一样。DSRPAG是0x00 01,模拟器崩溃从RAM的EDS页1读取(而不是从程序存储器读取)4。没有警告,没有错误。但是代码是完全错误的。5。没有警告,没有错误。代码好。DSRPAG被设置为UnWord指令=MyFlash存储器;6。没有警告,没有错误。代码好。代码与5略有不同,问题是3。4。在那里你既没有警告也没有错误,但是这些值是从ELSE读取的,而不是从程序内存中的常量读取的。
以上来自于百度翻译
以下为原文
Let my clarify:
I checked several ways to declare the buffer in Flash:
1. const unsigned int myFlashMemory[32]={1,2,3,4,5,6,7,8};
2. const unsigned int __attribute__((address(0x15000))) myFlashMemory[32]={1,2,3,4,5,6,7,8};
3. const unsigned int __attribute__((space(psv),address(0x15000))) myFlashMemory[32]={1,2,3,4,5,6,7,8};
4. const unsigned int __attribute__((space(prog),address(0x15000)))myFlashMemory[32]={1,2,3,4,5,6,7,8};
5. __psv__ const unsigned int __attribute__((space(prog),address(0x15000))) myFlashMemory[32]={1,2,3,4,5,6,7,8};
6. __eds__ const unsigned int __attribute__((space(prog),address(0x15000))) myFlashMemory[32]={1,2,3,4,5,6,7,8};
Some of the definitions are causing trouble.
(used the Simulator for this Test)
1. The compiler places the constants at a section named ".const" (in my Example located at 0x000300)
LowWordInstructions[k]
=myFlashMemory[k}; code is OK.
The compiler has set DSRPAG anywhere in the non-visible code to 0x0200 and reads the first word of myFlashSpace with MOV [W0],.. with W0=0x8300 i.e. offset 0x0300 and Bit 15 set to indicate PSV/EDS access.
2. An address is where the constants are placed.
In this case the compiler generates a
warning:
warning: myFlashMemory Not placing into compiler managed PSV section due to address(); assuming space(psv) for 'myFlashMemory'.
The Constants are placed in Flash at address 0x15000 and the code is similar to 1. But DSRPAG is set to 0x0001 instead of 0x0202. (0x000000 ... 0x007FFF->DSPRPAG=0x200; 0x008000...0x00FFFF->DSPRPAG=0x0201; 0x010000...0x017FFF->DSPRPAG=0x0202) So the results are wrong and sometimes running this code the Simulator crashes (no single-stepping, no reset, no Finish Debug Session possible. Restart of MPLAB X (v3.45) required)
3.Explicit using space(psv):
No warnings, no errors, constants placed in Flash at 0x15000. Same Problem as with 2. DSRPAG is 0x0001 and simulator crashes reading from EDS-Page 1 of RAM (instead of reading from Program memory)
4.
No warnings, no errors. But code is totally wrong.
5.
No warnings, no errors.
Code OK. DSRPAG is set explictite for LowWordInstructions
=myFlashMemory;
6.
No warnings, no errors.
Code OK. Code slightly different from 5.
The problems are 3. and 4. where you get neither warning nor errors but the values are read from elswhere but not from the constants in program memory.
让我澄清一下:我检查了几种在Flash中声明缓冲区的方法:1。const无符号int MyFlash内存[32 ]={1,2,3,4,5,6,7,8};2。const无符号int yAtAtditTyx((地址(0x15000)))MyFlash存储器[32 ]={1,2,3,4,5,6,7,8};3。const无符号int yAtAtditTyx((空间(PSV),地址(0x15000)))MyFlash存储器[32 ]={1,2,3,4,5,6,7,8};4。const无符号int yAtAtditTyx((空间(PROG),地址(0x15000)))MyFlash存储器[32 ]={1,2,3,4,5,6,7,8};5。(32)[1,2,3,4,5,6,7,8};6。(32){ 1,2,3,4,5,6,7,8};一些定义引起麻烦。(使用本测试的模拟器)1。编译器将常数放置在名为“.const”(在我的例子位于0x000 0300)的LoWordDebug [K]=MyFlash内存[k}的区段中,代码是OK的。编译器将DSRPAG设置在不可见代码中的任何地方到0x0200,并用MOV[W0]读取MyFlash空间的第一个字。W0=0x8300,即偏移0x0300和比特15设置为指示PSV/EDS访问。2。一个地址是放置常量的地方。在这种情况下,编译器生成警告:MyFlash内存不被放置到编译器管理的PSV部分(由于地址());假设空间(PSV)为“MyFlash内存”。常量放置在地址为0x15000的Flash中,代码类似于1。但是DSRPAG被设置为0x001而不是0x0202。(0x00万…0x07FFF-&;DSPPAGG=0x200;0x00 8000…0x00 FFFF & &;DSPPAG=0x0201;0x010000…0x017FFF & &;dSPPAG=0x0202),因此结果是错误的,有时运行此代码模拟器崩溃(没有单步执行,没有重置,没有完成调试会话可能)。重新启动MPLAB X(V3.45)需要3.3显式使用空间(PSV):没有警告,没有错误,常量放置在闪存在0x15000。同样的问题和2一样。DSRPAG是0x00 01,模拟器崩溃从RAM的EDS页1读取(而不是从程序存储器读取)4。没有警告,没有错误。但是代码是完全错误的。5。没有警告,没有错误。代码好。DSRPAG被设置为UnWord指令=MyFlash存储器;6。没有警告,没有错误。代码好。代码与5略有不同,问题是3。4。在那里你既没有警告也没有错误,但是这些值是从ELSE读取的,而不是从程序内存中的常量读取的。
以上来自于百度翻译
以下为原文
Let my clarify:
I checked several ways to declare the buffer in Flash:
1. const unsigned int myFlashMemory[32]={1,2,3,4,5,6,7,8};
2. const unsigned int __attribute__((address(0x15000))) myFlashMemory[32]={1,2,3,4,5,6,7,8};
3. const unsigned int __attribute__((space(psv),address(0x15000))) myFlashMemory[32]={1,2,3,4,5,6,7,8};
4. const unsigned int __attribute__((space(prog),address(0x15000)))myFlashMemory[32]={1,2,3,4,5,6,7,8};
5. __psv__ const unsigned int __attribute__((space(prog),address(0x15000))) myFlashMemory[32]={1,2,3,4,5,6,7,8};
6. __eds__ const unsigned int __attribute__((space(prog),address(0x15000))) myFlashMemory[32]={1,2,3,4,5,6,7,8};
Some of the definitions are causing trouble.
(used the Simulator for this Test)
1. The compiler places the constants at a section named ".const" (in my Example located at 0x000300)
LowWordInstructions[k]
=myFlashMemory[k}; code is OK.
The compiler has set DSRPAG anywhere in the non-visible code to 0x0200 and reads the first word of myFlashSpace with MOV [W0],.. with W0=0x8300 i.e. offset 0x0300 and Bit 15 set to indicate PSV/EDS access.
2. An address is where the constants are placed.
In this case the compiler generates a
warning:
warning: myFlashMemory Not placing into compiler managed PSV section due to address(); assuming space(psv) for 'myFlashMemory'.
The Constants are placed in Flash at address 0x15000 and the code is similar to 1. But DSRPAG is set to 0x0001 instead of 0x0202. (0x000000 ... 0x007FFF->DSPRPAG=0x200; 0x008000...0x00FFFF->DSPRPAG=0x0201; 0x010000...0x017FFF->DSPRPAG=0x0202) So the results are wrong and sometimes running this code the Simulator crashes (no single-stepping, no reset, no Finish Debug Session possible. Restart of MPLAB X (v3.45) required)
3.Explicit using space(psv):
No warnings, no errors, constants placed in Flash at 0x15000. Same Problem as with 2. DSRPAG is 0x0001 and simulator crashes reading from EDS-Page 1 of RAM (instead of reading from Program memory)
4.
No warnings, no errors. But code is totally wrong.
5.
No warnings, no errors.
Code OK. DSRPAG is set explictite for LowWordInstructions
=myFlashMemory;
6.
No warnings, no errors.
Code OK. Code slightly different from 5.
The problems are 3. and 4. where you get neither warning nor errors but the values are read from elswhere but not from the constants in program memory.
举报