找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 13745|回复: 8
收起左侧

我的程序在编译的时候总显示Target not created 怎么回事啊求大神解答

[复制链接]
ID:256712 发表于 2017-12-25 17:58 | 显示全部楼层 |阅读模式

#include<reg51.h>
#define uint unsigned int
#define uchar unsigned char
unsigned char KeyValue;
uint count;
uchar a,b,c,d,symbol,amount,KEY;
uchar code table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff};
void Delay(uint nms)
{
uint i,j;
for(i=nms;i>0;i--)
  for(j=110;j>0;j--)
  ;
}
void Display()
   {
     P0=table[a];
  a=0;
  Delay(5);
  a=1;
  P0=table[b];
  b=0;
  Delay(5);
  b=1;
  P0=table[c];
  c=0;
  Delay(5);
  c=1;
  P0=table[d];
  d=0;
  Delay(5);
  d=1;
}
void Key()
{
KEY=0x0f;
if(KEY!=0x0f)//读取按键是否按下
{
  Delay(1);//延时10ms进行消抖
  if(KEY!=0x0f)//再次检测键盘是否按下
  {
   
   //测试列
   KEY=0X0F;//10000
   switch(KEY)
   {
    case(0X07): KeyValue=0;break;
    case(0X0b): KeyValue=1;break;
    case(0X0d): KeyValue=2;break;
    case(0X0e): KeyValue=3;break;
   }
   //测试行
   KEY=0XF0;
   switch(KEY)
   {
    case(0X70): KeyValue=KeyValue+12;break;
    case(0Xb0): KeyValue=KeyValue+8;break;
    case(0Xd0): KeyValue=KeyValue+4;break;
    case(0Xe0): KeyValue=KeyValue+0;break;
   }
   while (KEY!=0xf0);  //检测按键松手检测
  }
  
}
}
void main()
{
     KeyValue=13;
     a=b=c=d=10;
     while(1)
  {
  
  while(count==0)
  {   
     Display();
     Key();
      if(KeyValue<=9)
        {
       a=KeyValue;
    count++;
    KeyValue=13;
       }
  }
  while(count==1)
  {
      Display();
   Key();
   while(KeyValue!=13)
   {
     if(KeyValue>9)
      {
        if(KeyValue==10)
     {
          symbol=0;
       count++;
       KeyValue=13;
     }
     if(KeyValue==11)
     {
           symbol=1;
        count++;
        KeyValue=13;
     }
      
         }
   }
  }
  while(count==2)
    {
       Display();
          Key();
    while(KeyValue!=13)
    {
            if(KeyValue<=9)
              {
             b=KeyValue;
          count++;
          KeyValue=13;
              }
     }
    }
    while(count==3)
    {
        Display();
         if(symbol==0)
      {
           amount=a+b;
      
      }
      if(symbol==1)
       {
           amount=a-b;
       }  
       c=amount/10;
       d=amount%10;
  
    }  
  
  }
}

回复

使用道具 举报

ID:266672 发表于 2017-12-25 18:27 | 显示全部楼层
输出的错误信息是什么?
回复

使用道具 举报

ID:258566 发表于 2017-12-25 18:56 | 显示全部楼层
uchar a,b,c,d,symbol,amount,KEY;




void Key()




回复

使用道具 举报

ID:258566 发表于 2017-12-25 19:02 | 显示全部楼层
修改后编译正常,虽然C语言是区分大小写的,但是l51连接器可能有问题。
回复

使用道具 举报

ID:266671 发表于 2017-12-25 19:37 | 显示全部楼层
void main()
{
     KeyValue=13;
     a=b=c=d=10;
     while(1)
  {
回复

使用道具 举报

ID:266764 发表于 2017-12-25 21:28 | 显示全部楼层
一般是语法错误,比如少加分号什么的,如果是用keil写的程序,可以直接点击显示错误的框里面那一行,系统会指出你的错误
回复

使用道具 举报

ID:97438 发表于 2017-12-26 10:19 | 显示全部楼层
keilc51编译器中,大小写都会认为是大写。。。所以,不要仅依赖大小写来区分变量或者函数。
回复

使用道具 举报

ID:97438 发表于 2017-12-26 10:20 | 显示全部楼层
#include<reg51.h>
#define uint unsigned int
#define uchar unsigned char
unsigned char KeyValue;
uint count;
uchar a,b,c,d,symbol,amount,KEY;
uchar code table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff};
void Delay(uint nms)
{
uint i,j;
for(i=nms;i>0;i--)
  for(j=110;j>0;j--)
  ;
}
void Display()
   {
     P0=table[a];
  a=0;
  Delay(5);
  a=1;
  P0=table[b];
  b=0;
  Delay(5);
  b=1;
  P0=table[c];
  c=0;
  Delay(5);
  c=1;
  P0=table[d];
  d=0;
  Delay(5);
  d=1;
}
void Key_Scan()
{
KEY=0x0f;
if(KEY!=0x0f)//读取按键是否按下
{
  Delay(1);//延时10ms进行消抖
  if(KEY!=0x0f)//再次检测键盘是否按下
  {
   
   //测试列
   KEY=0X0F;//10000
   switch(KEY)
   {
    case(0X07): KeyValue=0;break;
    case(0X0b): KeyValue=1;break;
    case(0X0d): KeyValue=2;break;
    case(0X0e): KeyValue=3;break;
   }
   //测试行
   KEY=0XF0;
   switch(KEY)
   {
    case(0X70): KeyValue=KeyValue+12;break;
    case(0Xb0): KeyValue=KeyValue+8;break;
    case(0Xd0): KeyValue=KeyValue+4;break;
    case(0Xe0): KeyValue=KeyValue+0;break;
   }
   while (KEY!=0xf0);  //检测按键松手检测
  }
  
}
}
void main()
{
     KeyValue=13;
     a=b=c=d=10;
     while(1)
  {
  
  while(count==0)
  {   
     Display();
     Key_Scan();
      if(KeyValue<=9)
        {
       a=KeyValue;
    count++;
    KeyValue=13;
       }
  }
  while(count==1)
  {
      Display();
   Key_Scan();
   while(KeyValue!=13)
   {
     if(KeyValue>9)
      {
        if(KeyValue==10)
     {
          symbol=0;
       count++;
       KeyValue=13;
     }
     if(KeyValue==11)
     {
           symbol=1;
        count++;
        KeyValue=13;
     }
      
         }
   }
  }
  while(count==2)
    {
       Display();
          Key_Scan();
    while(KeyValue!=13)
    {
            if(KeyValue<=9)
              {
             b=KeyValue;
          count++;
          KeyValue=13;
              }
     }
    }
    while(count==3)
    {
        Display();
         if(symbol==0)
      {
           amount=a+b;
      
      }
      if(symbol==1)
       {
           amount=a-b;
       }  
       c=amount/10;
       d=amount%10;
  
    }  
  
  }
}
回复

使用道具 举报

ID:97438 发表于 2017-12-26 10:20 | 显示全部楼层
改后能正常编译。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

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