打印
[开发工具]

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

[复制链接]
8973|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 | 只看该作者

~

谢谢两位

使用特权

评论回复
5
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

粉丝