IAR中通过ICF指定某变量的地址 或者 通过语句指定

来源:互联网 发布:中国出口数据统计 编辑:程序博客网 时间:2024/06/05 22:32

如果想定在rom空间

icf中:

place at address mem:0x08090000 { readonlysection .test };

C:中:

#pragma location = ".test"

const u32 uiData[512];// const 切不可省略 

如果想定在ram空间 

icf中: 

place at address mem:0x08090000 { readwritesection .test }; 

C:中:

#pragma location = ".test"

u32 uiData[512];

可发现uiData的值为0x08090000

该法可方便通过ICF指定某变量的地址。

程序也可以。写法类似.vector

如果用block的方。类似

define block CSTACK    with alignment = 8, size =__ICFEDIT_size_cstack__   { };

C中: 

#pragma language="extended"

#pragma segment="CSTACK"

ptr = __sfe( "CSTACK" );可得到CSTACK的高端地址+1

__sfe: Returns last address of segment.

 

另一种方法是通过语句指定,在网上没找到明确的答案,一本郑爱钧的书上面有。