[转载]【IAR Error】IAR MSP430编译报错:error

来源:互联网 发布:mac os 登录界面 其他 编辑:程序博客网 时间:2024/06/05 19:27

无编号警告类型:

1、Sat Jun 23, 2012 17:41:05: The stack pointer for stack 'Stack' (currently Memory:0xF5336) is
原因:http://blog.sina.com.cn/s/blog_4c0cb1c0010153l9.html

    

IAR相关设置:Tools->Option->Stack->Warn when stack pointer is out of bounds.

 

2、无法查看结构体/共同体/联合体 变量[Syntax error, unexpected $end, expecting COLON2] column 1

  struct  drpoint
  {
     uint16 x;
     uint16 y; 
  }drpoint[10];
 

改成:

  struct  

  {
     uint16 x;
     uint16 y; 
  }drpoint[10];
 

参考:http://tech.groups.yahoo.com/group/lpc2000/messages/34213?threaded=1&m=e&var=1&tidx=1

 

IAR 各版本BUG错误修正历史:ftp://efo-6.ip.peterstar.net/pub/efo-ftp/TMP/pub/atmel/_AVR32_MCUs_32bit/Compilers/IAR/IAR_2.20/Install software/EWAVR32-KS-CD-220A/doc/common/doc/CorrectedProblems.pdf

有编号警告类型:

 

Error[e16]: Segment XDATA_Z (size: 0x19a1 align: 0) is too long for segment definition. At least 0xe4c more bytes needed. The problem occurred while processing the segment placement command
"-Z(XDATA)XDATA_N,XDATA_Z,XDATA_I=_XDATA_START-_XDATA_END", where at the moment of placement the available memory ranges were "XDATA:f1ff-fd53"

Reserved ranges relevant to this placement:
XDATA:f000-f1fe XSTACK
XDATA:f1ff-fd53 XDATA_N
BIT:0-7 BREG
BIT:80-97 SFR_AN
BIT:a8-af SFR_AN
BIT:b8-c7 SFR_AN
BIT:d8-df SFR_AN
BIT:e8-ef SFR_AN

A:

其实这个问题并不是你的程序本身有问题,主要是因为你编写的程序太大了,超出了芯片本身的定义。今天在群里学习了一招,就是将数组定义到code里,我们看一下例子。我们定义一个5100个元素的数组,有以下两种方法:

mermaid提出的方法是:

typedef unsigned char const __code INT8U;

extern INT8U shuzi[5100];

文晶提出的方法是

INT8U code shuzi[5100];

这两种方法其实效果是一致的,定义完数组之后,调用的部分就是需要用指针来调用数组里面的数值了。

Error[e16]: Segment DATA16_I (size: 0xa80 align: 0x1) is too long for segment definition. At least 0x27f more bytes needed. The
pro××em occurred while processing the segment placement command
"-Z(DATA)DATA16_I,DATA16_Z,DATA16_N,HEAP+_HEAP_SIZE=0200-0A00", where at the moment of placement the ××aila××e
memory ranges were "CODE:200-A00"

经过验证是由于RAM耗尽,程序里估计有很大的数据量,最好使用const定义到FLASH里面,问题基本可以解决。

2Q: 

烧写程序时无法跳入断点
为什么我每次烧程序都出现:The stack plug-in failed to set a breakpoint on "main". The Stack window will not be able to display stack contents. (You can change this setting in the Tool>Options dialog box.)的警告。但是程序能烧进去,只是不能调试。

A:

确认设置没有问题(和好用的工程相比)这是设置不对,请找下面顺序修改:

iar->options->linker->output->format;
选择 Debug information for c-SPY选项
 

 

3Q:


 

错误提示:

Fatal Error[Cp001]: Copy protecTIon check, No valid license found for this product [20]

 

A:

可以将IAR全部安装上,但是在编译文件时却会报这个错,原因是安装的时候没有把注册机的0x.....字串的小写字母改为大写字母。

 

4Q:
“Error[e16]: Segment CSTACK (size: 0x50 align: 0x1) is too long for segment definition. At least 0x50 more bytes needed. The problem occurred while processing the segment placement command "-Z(DATA)CSTACK+_STACK_SIZE#", ”

A:


此错误是所定义的全局变量和数组缓冲区等所占的RAM超出硬件支持所致:size: 0x50为超出的大小。只要减少不不要的全局变量和尽量缩小数组缓冲区就可以了!

 

5Q:

 

7Q:

 

Error[Pe018]: expected a ")" C:Documents and SettingsAdministrator桌面CraneCrane塔吊防碰撞系统1.1版(SIM908 倾角查询)5438A塔吊防碰撞1.1api_function.h 5

 

1、函数或者语句中有变量名复用:

#define length 50                   // 吊臂长度

extern int dec_to_bcd(int dec_dat, unsigned char *bcd, int length);

将以上的变量名之一换做别的即可解决。

 

UESTC 2012.3.27

 

 Error[e27]:(变量没有extern声明外部可调用)  uestc

http://blog.sina.com.cn/s/blog_4c0cb1c00100z0w1.html
Error[e27]: Entry "ER_WARN" in module AD (……) redefined in module FINGERPRINT (……)

解决方法是把变量定义在其中一个cpp文件里面,
然后在另一个文件里面用extern来引用。
sample:

文件一:
int a=0;

文件二:
extern int a;  //此处不能使他等于某个数就可以了

 

以为我在x.h文件中定义有变量,然后x.h放入 config.h中,config.h被其他的各个.c文件包含,就造成了,x.h中的变量在各个.c中定义,造成了重复定义。 UESTC 2012.3.27

相关问答:

http://topic.csdn.net/u/20120222/22/c9b258d3-f58e-49dc-bf97-630271a26dfc.html

 

 

14Q:Error[e46]:

   Undefined external "__program_start" referred in ?ABS_ENTRY_MOD ( )

A:该问题应该是IAR设置问题,具体设置如下:
Project->Option->Linker->Config 勾选"Override default program"
再选择"Defined by application"

 

 B、 static  (const)变量是不能被外部文件调用的

 

 

Error[Pe077]:

this declaration has no storage class or type specifier

 

   不同的版本,就有不同的写法,就像环境不一样,中断函数的名字也不一样,我遇到过这样的情况(两个不同版本下定时器初始化时寄存器的名称不同).
   如I/O口中断函数的名的两种版本:
 
 版本1:interrupt[PORT2_VECTOR] void PORT2 (void)
 
 版本2:#pragma vector=PORT1_VECTOR
        __interrupt void PORT1_ISR (void)

2012.2.x UESTC


8Q:


Error[Pe136]:

     struct "<unnamed>" has no field "SampleApp_Periodic_DstAddr" D:Program FilesTexas InstrumentsZStack-1.4.3-1.2.1ProjectszstackSamplesSampleAppSourceSampleApp.c 417


//--------------------------------------------//
afAddrType_t dstAddr;
dstAddr.addrMode = afAddrBroadcast;
dstAddr.addr.shortAddr = 0xFFFF; // 广播发送 cdwxl
dstAddr.endpoint = SAMPLEAPP_ENDPOINT; //error所在
//--------------------------------------------//

A:


我们看看afAddrType_t这个结构就明白错在哪里了。

typedef struct
{
union
{
uint16 shortAddr;
} addr;
afAddrMode_taddrMode;
byteendPoint;
} afAddrType_t;

居然是 endPoint 大小写错误,Ω 。

 

9Q:


我最开始也是IAR仿真时找不到main函数,
显示:
Fri Jun 11 14:37:00 2010: Error (col 1): Unknown or ambiguous symbol. main
Fri Jun 11 14:37:01 2010: Error (col 1): Unknown or ambiguous symbol. main
Fri Jun 11 14:37:01 2010: Couldn't go to 'main'.

之后在project==>options==>linker里面的format设成debug,没有这个问题了,但是
程序又不能通过TI的那个Flash Programmer下载到板子里了,说是Could not open specified HEX file

A:

这个烧录工具只认release code. 而且扩展名必须是.hex。

所以要用这个烧录工具来烧录必须做两件事:

1. output file设为release version
2. output file 扩展名改为.hex, 默认的是.a51

测试学习阶段可以不用.但产品量产就必须生成二进制文件.
同时programmer还有些其它的功能会常用的

 Error[Pe142]: expression must have pointer-to-object type 

 

表达式两边的类型不一样。2012.2.x uestc

例如:

 “编译的错误是指第一个‘*’的后面应该是指针,却给了是非指针表达式。
如果p是个指针,那么*(p+i)是p后面第i个域或单元的元素,这个域与p所指的变量类型有关,
也就是说'*(p+i)+j'是数,而非指针。与*结合就错了。 ”

http://www.ourdev.cn/bbs/bbs_content.jsp?bbs_sn=931945 

 

C++的该错误:

http://efreedom.com/Question/1-4943607/Expression-Must-Pointer-Object-Type-Subscript-Requires-Array-Pointer-Type

Error[Pe148]:

variable "TA1R_OVERFLOW" has already been initialized

 

"unsigned char TA1R_OVERFLOW=0; " 声明可外部调用需要赋值

 

 

Error[Pe159]: declaration is incompatible with previous

 

  没加头文件,或者主函数内有子函数,而子函数定义在主函数后边而木有在主函数前声明一下。

 

Error[Pe169]: expected a declaration

错误原因可能性:

1、void read_gprs_return();

{

……

}

定义函数的时候,结尾多了一个分号:;。

 

Error[Pe852]:

Error[Pe852]:expression must be a pointer to a complete object type

 

请教关于结构体数组的引用出错

yanzhongwang
2006-02-24, 14:30
定义结构体数组
var.c:
struct StructDisData
{
unsigned int AddrDisData;
unsigned int TypeDisChar;
unsigned int TypeDisUnit;
unsigned char LengthDisData;
};

const struct StructDisData StrDisData[254]={.....};

var.h:
const extern struct StructDisData StrDisData[254];

在Lunxian.c中引用:
#include "var.h"

unsigned int vAdd;
void Sub1(void)
{
unsigned int disptr;
disptr =...;
vAdd =StrDisData[disptr].AddrDisData; //编译时在此处出错 Error[Pe852]: expression must be a pointer to a complete object type

}
各位大虾请帮我分析一下 谢谢!
erlking
2006-02-24, 14:41
改成
vAdd =StrDisData[disptr]->AddrDisData;
试试?
yanzhongwang
2006-02-24, 14:58
谢谢erking这么快的回复!
我改了试了一下 还是一样的错误
好像->是用指针方式调用才用到
li_hai_tao930
2006-02-24, 23:19
声明结构体时用typedef 定义结构类型名试试
iltgcl
2006-02-27, 08:36
将结构定义
struct StructDisData
{
unsigned int AddrDisData;
unsigned int TypeDisChar;
unsigned int TypeDisUnit;
unsigned char LengthDisData;
};
放到头文件中,即.h文件中
yanzhongwang
2006-02-27, 10:59
谢谢楼上的各位!
用iltgcl的方法试了一下 编译没问题了!
yanzhongwang
2006-02-27, 11:22
改正后的文件结构如下
var.c:

var.h:
struct StructDisData
{
unsigned int AddrDisData;
unsigned int TypeDisChar;
unsigned int TypeDisUnit;
unsigned char LengthDisData;
};

Lunxian.c:
#include "var.h"
unsigned int vAdd;
const struct StructDisData StrDisData[254]={.....};
void Sub1(void)
{
unsigned int disptr;
disptr =...;
vAdd =StrDisData[disptr].AddrDisData; 
}
再次谢谢各位工程师的热心指点!
readyaiming
2006-03-03, 15:23
不错不错。

Error[Pe260]:

 

   explicit type is missing ("int" assumed) C:Documents and SettingsAdministrator桌面下位机塔吊防碰撞系统1.1版(SIM908 倾角查询)5438A塔吊防碰撞1.1LCD(SmallFonts).c 898

 

问题例子1:定义一个函数,落了红字部分声明

void DrawSector(int x,int y,int R1,int R2,float Ds ,float De,int fill,uchar color)
{
    ……

}

 

 

11Q:Error[Pe513]:

   a value of type "int (*)(uint8, uint8)" cannot be assigned to an entity of type "halUARTCBack_t" D:Program FilesTexas InstrumentsZStack-1.4.3-1.2.1Componentsstacksapisapi.c 968

A:估计是一个函数本没有返回值即void类型,而你却将这个函数赋给了一个int型变量了。。

static rxCB( uint8 port,uint8 event )改为
static void rxCB( uint8 port,uint8 event )

12Q:
 

Fatal Error[e72]: Segment BANK_RELAYS must be defined in a segment definition option (-Z, -b or -P)

A:


使用无线龙的串口互发,发现上述错误,原因是版本太高,具体原因不清,下载一下7.20H就可以了

 

Fatal Error[e89]: Too much object code produced (more than 0x1000 bytes) for this package

是4K限制版,请使用有非限制版的。

 

 

IAR常见错误请先从如下几方面入手:

1序列号是否正确。

2使用版本是否正确,应该使用7.30B打开的工程文件不能使用7.20H打开。

       3尽量不要使用中文路径。

       4ZigBee协议栈文件夹需要放在IAR安装盘根目录下。

       5请确定当前编译文件夹是否具有读写权限。

       6使用的版本是否是限制版

 

 

 

Fatal Error[Pe005]: could not open source file "stdio.h" 这是什么原因?谢谢了

是因为头文件路径不对造成,改正的方法是在设置选项卡的C/C++ Compiler -> Preprocessor选项里,将$TOOLKIT_DIR$INCCLIB添到Include paths中。($TOOLKIT_DIR$指IAR的安装路径,一般用到标准库函数时要将它写入Include paths里面)

 

 

Fatal Error[Pe005]: could not open source file "hal.h" C:UsersuserDesktop例子程序无线通信综合测试Librarycc2430HALsourcesetTimer34Period.c 7

先检查 C:UsersuserDesktop例子程序无线通信综合测试Librarycc2430HALsource有无setTimer34Period.c 这个文件,若有,则是因为IAR对中文路径支持不好的缘故,你把这个工程复制到全英文路径下编译应该就不会报错了。

Fatal Error[Pe1696]: cannot open source file "config.h"

注意config.h 存放的位置,最好与main同处于一个文件夹

15Q:

Fatal Error[Cp001]:

   Copy protection check, No valid license found for this product [24]
XP下装的IAR,到了Win7下出来的问题。

A:这个问题是使用注册机带来的,系统换了,本机ID也要改了。

、、单击IARID.EXE得到本机的ID号
、、右键点Key.cmd,选择编辑,打开,将ID修改为本机ID
、、运行KEY.cmd,在key.txt中的含有EW8051-EV的序列号就是7.30的序列号

16Q:

在用iar debug 下载进已有程序板子出现的

A:将核心板与扩展板分开,只烧写核心板。

 

17Q:



A:自小峰关于协议栈XDATA溢出的小结
(1)减小程序;

(2)把配置文件f8w2430.xcl/f8w2430pm.xcl中的-D_CODE_END改大点:
********************
f8w2430.xcl:
// CODE
//
// These settings determine the size/location of the ROOT segment.
// Increase _CODE_END to increase ROOT memory, i.e. for constants.
-D_CODE_START=0x0000 // Code size = 128k for CC2430-F128
-D_CODE_END=0x4000 // Last address for ROOT bank
********************
f8w2430pm.xcl:
// CODE
//
// These settings determine the size/location of the ROOT segment.
// Increase _CODE_END to increase ROOT memory, i.e. for constants.
-D_CODE_START=0x0000 // Code size = 128k for CC2430-F128
-D_CODE_END=0x29FF //(原0x28FF) Last address for ROOT bank

 

 

Warning[Pe001]: last line of file ends without a newline F:emoTionIARPK升级CC1110-8main.c 179
A:

在使用IAR时常常会弹出类似这样一个警告,其实只要在最后一行多加一个回车就不会再有这个警告了.

 

 

6Q:

在编写一个串口程序时:编译没有错,但MAKE时就出现下面的错误

undefined external“UART1_ISR”referred in startup

A:

串口1中断向量没有定义,实际上是串口1中断向量定义其他名称,而不是UART1_ISR.

 

出现这样的调试IAR错误时:Fatal error: Unknown exception in driver (#E1),是因为IAR软件没有跟Texas Instruments文件放在同一个系统盘下

 

Warnin[w6]: 

   Type conflict for external/entry "_A_PORTD", in module _ultrasonic against external/entry in module _ST7920; class/struct/union types have  
different numbers of fields/bases 

你看看你的源代码里函数是不是这样写:void XXX(void)

而.h代码里这样声明:void XXX();

.h代码应该这样声明:void XXX(void);
 

 

分析:一般Warnin[w6]:问题出在头文件里头,可能有:

1、声明了外部变量,但是用到那个函数的.c文件没有包含那个头文件

2、源代码函数和.h里声明的函数不一样:.c里 void XXX(void),头文件中:void XXX();或者:笔误.hz中  Wight_warn (); .c中: Weight_warn();
3、在.C中定义了,但是没有extern void clean_uart2_rx_buff();声明外部可调用,然后外部调用了它,就有可能出现。 2012.3.26 UESTC


 

Warning[Pe009]: nested comment is not allowed    

注释最好不要嵌套
例如注释1后半部*/

 

就是最好不要这样     uestc

 

 Warning[Pa082]:

 undefined behavior: the order of volatile accesses is undefined in this statement

 

 

运算符两边都是volatile变量的警告

 

这警告有意义.
volatile 意思是:易变的。
用volatile修饰的变量一般不直接参与运算(在运算中值可能在变化),volatile就以为这个变量在运算过程中有可能已经改变了


例如:想计算a * b 要这样:

volatile unsigned char a;volatile unsigned char b;unsigned char x,y;x = a;y = b;return (x * y);
复制代码


建议使用另外一个变量参与计算:

volatile char VVV = 9;char fun(){char xxx;char yyy = 9;xxx = VVV;return xxx * yyy}
复制代码
 
Warning[Pe175]: 
 

编译错误:Warning[Pe175]: subscript out of range 

          原因: 定义了 float value[6] ; 既我们定义的了 value[0]、 value[1]…… value[5],默认从0开始的,而实际中我们用到了value[6],越界了。

2011年 6月2日 

 Warning[Pe177]:

    function "rxCB" was declared but never referenced D:Program FilesTexas InstrumentsZStack-1.4.3-1.2.1Componentsstacksapisapi.c 982

A:函数虽定义但从未被引用(使用)。如果你需要使用该函数,就需要检查;否则略过。

13Q:
Fri Jun 11 14:37:00 2010: Error (col 1): Unknown or ambiguous symbol. main
Fri Jun 11 14:37:01 2010: Error (col 1): Unknown or ambiguous symbol. main
Fri Jun 11 14:37:01 2010: Couldn't go to 'main'.

A:project==>options==>linker 看看里面的format是不是设成debug
详见www.feibit.com/bbs/viewthread.php

 

 Warning[Pe186]: pointless comparison of unsigned integer with zero

 

无符号整数不可能小于0的……


10Q:Warning[Pe188]:

     enumerated type mixed with another type D:Program FilesTexas InstrumentsZStack-1.4.3ProjectszstackSamplesSampleAppSourceSampleApp.c 206

A: SampleApp_Periodic_DstAddr.addrMode = Addr16Bit;//(afAddrMode_t)afAddrGroup;
typedef enum
{
afAddrNotPresent = AddrNotPresent,
afAddr16Bit = Addr16Bit,
afAddrGroup = AddrGroup,
afAddrBroadcast = AddrBroadcast
} afAddrMode_t;
问题就在于Addr16Bit未加afAddrMode_t这个套子。

 

Warning[Pe1072]: a declaration cannot have a label  

在switch case:后直接定义变量了
 switch (check_storce_status())
  {
  case 0:
    break;
  case 1:
  int fash;
   break;
 case 2:
  break;
}
 
解决方法:
前后加个括号即可。
 switch (check_storce_status())
  {
  case 0:
    break;
  case 1:
  {
   int fash;
   break;
  }
 case 2:
  break;
 }
 UESTC 2012.3.19

 

 更多错误信息查看文档:http://pan.baidu.com/share/link?shareid=149069&uk=3894179906


原创粉丝点击