找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 902|回复: 1
打印 上一主题 下一主题
收起左侧

为什么Keil只有1个提醒,硬件无法显示?求助

[复制链接]
跳转到指定楼层
楼主
ID:496863 发表于 2019-3-23 20:19 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
#include <reg52.h>
#include <intrins.h>
   
typedef unsigned char INT8U;
typedef unsigned char uchar;
typedef unsigned int INT16U;
typedef unsigned int uint;
sbit DS = P3^6;
//sbit DU = P1;
//sbit WE = P2;
uchar code table[]={
//0  1  2     3     4     5     6     7     8
0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80,
//9     A     B    C  D    E  F  -  .   关显示
0x90, 0x88, 0x83, 0xC6, 0xA1, 0x86, 0x8E, 0xBF, 0x7F, 0xFF};
uchar code T_COM[] = {0xfe, 0xfd, 0xfb, 0xf7,};//数码管位码
/*us延时函数,执行一次US--所需6.5us进入一次函数需要11.95us*/
void Delay_us(uchar us)
{
while(us--);
}
/*====================================
函数 : delay(uint z)
参数 :z 延时毫秒设定,取值范围0-65535
返回值 :无
描述 :12T/Fosc11.0592M毫秒级延时
====================================*/
void delay(uint z)
{
uint x,y;
for(x = z; x > 0; x--)
  for(y = 114; y > 0 ; y--);   
}

void Display(INT16U Value)
{
  P1 = 0XFF;
  P2 = T_COM[1];
  P1 = table[Value/100];  
  delay(5);
  P1 = 0XFF;
  P1 = 0XFF;
  P2 = T_COM[2];
  P1 = table[Value%100/10]&0x7f;  
  delay(5);
  P1 = 0XFF;
  P1 = 0XFF;
  P2 = T_COM[3];
  P1 = table[Value%10];  
  delay(5);
  P1 = 0XFF;
  }
bit ds_init()
{
  bit i;
  DS = 1;
  _nop_();
  DS = 0;
  Delay_us(75);
  DS = 1;
  Delay_us(4);
  i = DS;
  Delay_us(20);
  DS = 1;
  _nop_();
  return(i);
}
void write_byte(uchar dat)
{
  uchar i;
  for(i=0;i<8;i++)
  {
    DS = 0;
    _nop_();
    DS = 1;
    DS = dat & 0x01;
    Delay_us(10);
    DS = 1; //释放总线准备下一次数据写入
    _nop_();
    dat >>= 1;
  }
}
uchar read_byte()
{
  uchar i, j, dat;
  for(i=0;i<8;i++)
  {
    DS = 0;
    _nop_();
    DS = 1;
    _nop_();
    j = DS;
    Delay_us(10);
    DS = 1;
    _nop_();
    dat = (j<<7)|(dat>>1);
  }
  return (dat);
}
void main()
{
  uint i=0;
  uchar L, M;  
/*  ds_init();
  write_byte(0xcc);
  write_byte(0x4e);
  write_byte(0x7f);
  write_byte(0xf7);
  write_byte(0x1f);
  ds_init();
  write_byte(0xcc);
  write_byte(0x48);*/
  while(1)
    {
    ds_init();
    write_byte(0xcc);
    write_byte(0x44);
    ds_init();//初始化DS18B20
    write_byte(0xcc);
    write_byte(0xbe);
    L = read_byte();
    M = read_byte();
    i = M;   
    i <<=8;
    i |= L;
    i = i * 0.0625 * 10 + 0.5;
    }
       {
        Display(i);   delay(10);
       }
}


linking...
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
    SEGMENT: ?PR?_DISPLAY?WHENG
Program Size: data=11.1 xdata=0 code=1193
creating hex file from "1"...
"1" - 0 Error(s), 1 Warning(s).

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:1 发表于 2019-3-24 02:10 | 只看该作者
您这个问题给的信息不全,估计是没人能回答得了的,先转移到冷门区了,自行点击编辑按钮补充一下吧,审核员会帮你重新转到热门问答区的
回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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