发 帖  
原厂入驻New
[问答]

keil编译error C141: syntax error near 'data' Target not created求指导

4478
分享
本帖最后由 踏云之步 于 2015-1-22 15:45 编辑

Build target 'Target 1'
compiling AD7705_eg1.c...
..\GRADUAtiONPROJECT\AD7705_EG1.C(54): error C141: syntax error near '='
..\GRADUATIONPROJECT\AD7705_EG1.C(55): error C141: syntax error near 'unsigned'
..\GRADUATIONPROJECT\AD7705_EG1.C(55): error C202: 'i': undefined identifier
..\GRADUATIONPROJECT\AD7705_EG1.C(58): error C202: 'i': undefined identifier
..\GRADUATIONPROJECT\AD7705_EG1.C(60): error C141: syntax error near '<<='
..\GRADUATIONPROJECT\AD7705_EG1.C(65): error C141: syntax error near '++'
..\GRADUATIONPROJECT\AD7705_EG1.C(72): error C141: syntax error near 'data', expected ';'
..\GRADUATIONPROJECT\AD7705_EG1.C(82): error C141: syntax error near '='
..\GRADUATIONPROJECT\AD7705_EG1.C(83): error C141: syntax error near 'unsigned'
..\GRADUATIONPROJECT\AD7705_EG1.C(83): error C202: 'i': undefined identifier
..\GRADUATIONPROJECT\AD7705_EG1.C(86): error C202: 'i': undefined identifier
..\GRADUATIONPROJECT\AD7705_EG1.C(88): error C141: syntax error near '<<='
..\GRADUATIONPROJECT\AD7705_EG1.C(91): error C202: 'AD_DOUT': undefined identifier
..\GRADUATIONPROJECT\AD7705_EG1.C(93): error C141: syntax error near '++'
..\GRADUATIONPROJECT\AD7705_EG1.C(100): error C141: syntax error near 'data', expected ';'
..\GRADUATIONPROJECT\AD7705_EG1.C(110): error C141: syntax error near '='
..\GRADUATIONPROJECT\AD7705_EG1.C(111): error C141: syntax error near 'unsigned'
..\GRADUATIONPROJECT\AD7705_EG1.C(111): error C202: 'i': undefined identifier
..\GRADUATIONPROJECT\AD7705_EG1.C(114): error C202: 'i': undefined identifier
..\GRADUATIONPROJECT\AD7705_EG1.C(116): error C141: syntax error near '<<='
..\GRADUATIONPROJECT\AD7705_EG1.C(119): error C202: 'AD_DOUT': undefined identifier
..\GRADUATIONPROJECT\AD7705_EG1.C(121): error C141: syntax error near '++'
..\GRADUATIONPROJECT\AD7705_EG1.C(128): error C141: syntax error near 'data', expected ';'
..\GRADUATIONPROJECT\AD7705_EG1.C(136): error C141: syntax error near ')'
..\GRADUATIONPROJECT\AD7705_EG1.C(138): error C141: syntax error near 'unsigned'
..\GRADUATIONPROJECT\AD7705_EG1.C(138): error C202: 'i': undefined identifier
..\GRADUATIONPROJECT\AD7705_EG1.C(138): error C202: 'i': undefined identifier
..\GRADUATIONPROJECT\AD7705_EG1.C(138): error C202: 'i': undefined identifier
..\GRADUATIONPROJECT\AD7705_EG1.C(138): error C141: syntax error near ')'
..\GRADUATIONPROJECT\AD7705_EG1.C(141): error C141: syntax error near 'data'
..\GRADUATIONPROJECT\AD7705_EG1.C(148): error C141: syntax error near 'data'
..\GRADUATIONPROJECT\AD7705_EG1.C(160): error C141: syntax error near ')'
..\GRADUATIONPROJECT\AD7705_EG1.C(166): error C141: syntax error near 'data'
..\GRADUATIONPROJECT\AD7705_EG1.C(173): error C141: syntax error near 'data'
Target not created
keil源程序如下:
#include <reg52.h>
#include <math.h>
#include <intrins.h>

//#define DIN(x) { if((x)) P0^1=1;else P0^1=0;}
//#define CLK(x) { if((x)) P0^2=1;else P0^2=0;}
sbit DIN=P0^1;
sbit CLK=P0^2;
sbit DRDY=P0^3;
sbit CS=P0^0;
sbit DOUT=P0^4;
//函数;delay()
void delay3us(void)
{
_nop_();
}
//函数;delay_ms
void delay_ms(void)   //误差 0us
{
    unsigned char a,b,c;
    for(c=1;c>0;c--)
        for(b=142;b>0;b--)
            for(a=2;a>0;a--);
}
//函数:reset_AD7705
//功能:AD7705串行接口失步后将其复位。复位后要延时500us再访问
//参数:无
//返回:无
//变量:无
//备注:无
void reset_AD7705(void)
{
unsigned char i;
DIN=1;
for( i=0; i<36; i++ )
{
CLK=0;
delay3us();

CLK=1;
delay3us();
}
delay_ms();
}

//函数:read_AD7705_byte
//功能:从AD7705读一个字节的数据
//参数:无
//返回:读到的一字节数据
//变量:无
//备注:无
unsigned char read_AD7705_byte(void)
{
unsigned char data = 0;
unsigned char i = 0;
DRDY=0;
CS=0;
for( i=0; i<8; i++ )
{
data <<= 1;
CLK=0;
delay3us();
if(DOUT)
{
data++;
}
CLK=1;
delay3us();
}
CS=1;
DRDY=1;
return data;
}
//函数:read_AD7705_word
//功能:从AD7705读一个字的数据,共16bit
//参数:无
//返回:读到的一字节数据
//变量:无
//备注:无
unsigned int read_AD7705_word(void)
{
unsigned int data = 0;
unsigned char i = 0;
DRDY=0;
CS=0;
for( i=0; i<16; i++ )
{
data <<= 1;
CLK=0;
delay3us();
if(AD_DOUT)
{
data++;
}
CLK=1;
delay3us();
}
DRDY=1;
CS=1;
return data;
}
//函数:read_AD7705_dword
//功能:从AD7705读一个24的数据
//参数:无
//返回:读到的一字节数据
//变量:无
//备注:AD7705是一个24位AD,选定刷新频率在16.7HZ下,有效位是19位,暂时读出全部24位数据
unsigned long int read_AD7705_dword(void)
{
unsigned long data = 0;
unsigned char i = 0;
DRDY=0;
CS=0;
for( i=0; i<24; i++ )
{
data <<= 1;
CLK=0;
delay3us();
if(AD_DOUT)
{
data++;
}
CLK=1;
delay3us();
}
DRDY=0;
CS=0;
return data;
}
//函数:write_AD7705_byte
//功能:往AD7705写8位数据
//参数:IN - uint8_t data,要写入AD7705的数据
//返回:无
//变量:无
//备注:无
void write_AD7705_byte(unsigned char data)
{
for(unsigned char i=0; i<8; i++)
{
CLK=0;
if(data&0x80)
DIN=1;
else
DIN=0;
delay3us();  
CLK=1;
delay3us();
data <<= 1;
}

DIN=1;
}
//函数:write_AD7705_dword
//功能:往AD7705写24位数据,因为AD7705是24位的器件
//参数:IN - int32_t data,要写入AD7705的数据
//返回:无
//变量:无
//备注:无
//------------------------------------------------------------------------------------------
void write_AD7705_dword(unsigned long int data)
{
unsigned char i;
for( i = 0; i<24; i++)
{
CLK=0;
if(data&0x800000)
DIN=1;
else
DIN=0;
delay3us();
CLK=1;
delay3us();
data <<= 1;
}

DIN=1;
}
//Function : AD7705Init()
void AD7705Init(void)
{
reset_AD7705();
//写时钟寄存器;
Write(0x20);
Write(0x07);
//写设置寄存器;
Write(0x10);
Write(0x46);
}
//返回一次采样值
unsigned int ReturndataAD7705(void)
{
while(DRDY==1);
Write(0x38);
return Read();
}

//平均温度值
unsigned int AverageTempAD7705(void)
{
unsigned long AverageTemp=0;
unsigned int i=0;
for(;i<1000;i++)
{
  AverageTemp+=(unsigned long)ReturndataAD7795();
}
return (unsigned long)(AverageTemp/1000);
}































0
2015-1-22 15:44:09   评论 分享淘帖 邀请回答
1个回答
"data" 是保留字,不可当变数。
2015-1-22 17:21:08 评论

举报

撰写答案

你正在撰写答案

如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。

高级模式
您需要登录后才可以回帖 登录 | 注册

声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容图片侵权或者其他问题,请联系本站作侵删。 侵权投诉
我要提问
关闭

站长推荐 上一条 /5 下一条

快速回复 返回顶部 返回列表