[应用相关] 如何设定指定地址的 FLASH 的值?

[复制链接]
2718|7
 楼主| zhang..yb 发表于 2008-10-31 11:23 | 显示全部楼层 |阅读模式
在 IAR 中,如何在编译时直接设定指定地址的 FLASH 的值
香水城 发表于 2008-10-31 11:25 | 显示全部楼层

直接赋值

*((unsigned int*)0x68000000) = 100;
 楼主| zhang..yb 发表于 2008-10-31 11:40 | 显示全部楼层

好象不行

在编译时设置和在运行时改写是不同的
香水城 发表于 2008-10-31 12:35 | 显示全部楼层

如何不同?你是如何写的?

xwj 发表于 2008-10-31 12:35 | 显示全部楼层

绝对定位或修改烧录(下载)文件

 楼主| zhang..yb 发表于 2008-10-31 12:56 | 显示全部楼层

回复

把一个变量可以定位在 FLASH 中的绝对地址上,但该变量不能赋初值。
程序运行中修改 FLASH 是 IAP 方式,我要的是编译后烧写就完成指定地址
的设置
香水城 发表于 2008-10-31 13:48 | 显示全部楼层

使用const属性

lixun00 发表于 2008-10-31 20:02 | 显示全部楼层

#pragma location={address|SEGMENT_NAME}

location 
Syntax 
#pragma location={address|SEGMENT_NAME} 
Parameters 

 address  The absolute address of the global or static variable for which you want an absolute location.  
SEGMENT_NAME  A user-defined segment name; cannot be a segment name predefined for use by the compiler and linker.  


Description 
Use this pragma directive to specify the location—the absolute address—of the global or static variable whose declaration follows the pragma directive. The variable must be declared either __no_init or const. Alternatively, the directive can take a string specifying a segment for placing either a variable or a function whose declaration follows the pragma directive. 

Example 
#pragma location=0xFFFF0400 
__no_init volatile char PORT1; /* PORT1 is located at address 
                                  0xFFFF0400 */ 
 
#pragma location="foo"  
char PORT1; /* PORT1 is located in segment foo */ 
 
/* A better way is to use a corresponding mechanism */ 
#define FLASH _Pragma("location="FLASH"") 
... 
FLASH int i; /* i is placed in the FLASH segment */ 
See also 
For additional information and examples, see the ARM® IAR C/C++ Compiler Reference Guide.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

103

主题

441

帖子

1

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