CCS关于volatile问题

[复制链接]
4508|9
 楼主| freeman05 发表于 2007-6-1 08:43 | 显示全部楼层 |阅读模式
当运行一下语句时;<br />unsigned&nbsp;int&nbsp;*iFlashAddr;<br />iFlashAddr=(volatile&nbsp;unsigned&nbsp;int*)0xffff;<br /><br />出现这样的错误提示:<br />&quot;flash.c&quot;,&nbsp;line&nbsp;49:&nbsp;error:&nbsp;a&nbsp;value&nbsp;of&nbsp;type&nbsp;&quot;volatile&nbsp;unsigned&nbsp;int&nbsp;*&quot;&nbsp;cannot&nbsp;be&nbsp;assigned&nbsp;to&nbsp;an&nbsp;entity&nbsp;of&nbsp;type&nbsp;&quot;unsigned&nbsp;int&nbsp;*&quot;<br /><br />请问这是为什么啊?
cehon 发表于 2007-6-1 10:24 | 显示全部楼层

如下

类型不匹配吧
acecao 发表于 2007-6-2 09:51 | 显示全部楼层

rr

该这样吧<br />iFlashAddr=*(volatile&nbsp;unsigned&nbsp;int*)0xffff
 楼主| freeman05 发表于 2007-6-2 10:43 | 显示全部楼层

这样

这样<br />iFlashAddr=*(volatile&nbsp;unsigned&nbsp;int*)0xffff<br /><br />就会这样了:<br />&quot;flash.c&quot;,&nbsp;line&nbsp;19:&nbsp;error:&nbsp;a&nbsp;value&nbsp;of&nbsp;type&nbsp;&quot;unsigned&nbsp;int&quot;&nbsp;cannot&nbsp;be&nbsp;assigned&nbsp;to&nbsp;an&nbsp;entity&nbsp;of&nbsp;type&nbsp;&quot;unsigned&nbsp;int&nbsp;*&quot;<br />
acecao 发表于 2007-6-2 19:21 | 显示全部楼层

感觉这两句代码要实现的功能是将I/O空间或数据空间FFFFh地址的内容当作FLASH程序的首地址。<br />unsigned&nbsp;int&nbsp;iFlashAddr;&nbsp;<br />iFlashAddr=*(volatile&nbsp;unsigned&nbsp;int*)0xffff;<br /><br />or:<br /><br />unsigned&nbsp;int&nbsp;*iFlashAddr;<br />*(iFlashAddr)=*(volatile&nbsp;unsigned&nbsp;int*)0xffff;<br /><br /><br />
zhr123456 发表于 2013-8-23 11:55 | 显示全部楼层
定义 int iFlashAddr;
iFlashAddr=*(volatile int *)0xffff;
zhangmangui 发表于 2013-8-23 13:42 | 显示全部楼层
受教了
aresc 发表于 2013-8-24 16:39 | 显示全部楼层
应该是:
volatile unsigned int *iFlashAddr;

iFlashAddr = (volatile unsigned int *)0xffff;
hczsea 发表于 2013-8-26 10:16 | 显示全部楼层
那就改成
volatile unsigned int *iFlashAddr;
iFlashAddr=(volatile unsigned int*)0xffff;
lelee007 发表于 2013-8-26 23:33 | 显示全部楼层
8L正解,其他都是扯淡
您需要登录后才可以回帖 登录 | 注册

本版积分规则

11

主题

36

帖子

0

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