[开发工具] IAR开发STM32,map里面有个CONST memory,在flash还是ram里?

[复制链接]
9990|4
 楼主| colaring 发表于 2008-8-28 16:40 | 显示全部楼层 |阅读模式

                ****************************************
                *                                      *
                *      SEGMENTS IN ADDRESS ORDER       *
                *                                      *
                ****************************************


SEGMENT              SPACE    START ADDRESS   END ADDRESS     SIZE  TYPE  ALIGN
=======              =====    =============   ===========     ====  ====  =====
INTVEC                             08000000 - 080000EB          EC   rel    2
ICODE                              080000EC - 0800014F          64   rel    2
DIFUNCT                                 08000150                     rel    2
CODE                               08000150 - 08018909       187BA   rel    2
INITTAB                            0801890C - 08018923          18   rel    2
DATA_ID                            08018924 - 08019A23        1100   rel    2
DATA_C                             08019A24 - 0801A0FF         6DC   rel    2
DATA_I                             20000000 - 200010FF        1100   rel    2
DATA_Z                             20001100 - 20001FAD         EAE   rel    2
CSTACK                             20001FB0 - 200023AF         400   rel    2

                ****************************************
                *                                      *
                *        END OF CROSS REFERENCE        *
                *                                      *
                ****************************************

 100 618 bytes of CODE  memory
   9 134 bytes of DATA  memory
   6 132 bytes of CONST memory

Errors: none
Warnings: none

请问这个“ 6 132 bytes of CONST memory”所在的位置
香水城 发表于 2008-8-28 17:09 | 显示全部楼层

根据它所在的地址可以看出在Flash

INITTAB                            0801890C - 08018923          18   rel    2
DATA_ID                            08018924 - 08019A23        1100   rel    2
DATA_C                             08019A24 - 0801A0FF         6DC   rel    2
lut1lut 发表于 2008-8-28 17:14 | 显示全部楼层

取决于你的linker file怎么写

一般在linker file中有这样的制定
-Z(CONST)INITTAB,DATA_ID,DATA_C=ROMSTART-ROMEND

而不同的linker file有对ROM的不同定义,例如:
<ram.xcl>
// Code and data in RAM
-DRAMSTART=0x20000000
-DRAMEND=0x2000FFFF

-DROMSTART=RAMSTART
-DROMEND=RAMEND

<flash.xcl>
// Code memory in FLASH
-DROMSTART=0x8000000
-DROMEND=0x807FFFF

// Data in RAM
-DRAMSTART=0x20000000
-DRAMEND=0x2000FFFF
 楼主| colaring 发表于 2008-8-28 20:26 | 显示全部楼层

~

谢谢两位
robin0557 发表于 2011-4-16 21:05 | 显示全部楼层
以下结论是实测得出的:
如果定义在函数内部,则占用RAM空间:0x200005f4
如果定义为全局变量则占rom空间。0x80064e4
帮助中“IAR C/C++ Development Guide”
描述如下:
DECLARING OBJECTS CONST
The const type qualifier is used for indicating that a data object, accessed directly or
via a pointer, is non-writable. A pointer to const declared data can point to both
constant and non-constant objects. It is good programming practice to use const
declared pointers whenever possible because this improves the compiler’s possibilities
to optimize the generated code and reduces the risk of application failure due to
erroneously modified data.
Static and global objects declared const are allocated in ROM.
In C++, objects that require runtime initialization cannot be placed in ROM.
也就是说如果定义在函数内部的话,需要加上static
您需要登录后才可以回帖 登录 | 注册

本版积分规则

44

主题

156

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部