帮忙解决

[复制链接]
 楼主| 奔跑着的水 发表于 2012-11-21 20:35 | 显示全部楼层 |阅读模式
电压表的程序,但是没有成功!!帮忙解决!!谢谢!!
#include<reg52.h>
#define uchar  unsigned char
#define uint   unsigned int
uchar code  dispcode[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
uchar  dispbuf[4]={0,0,0,0};
uchar  temp;
uchar  getdata;
uint    i,j;
void   delay();
sbit   OE=P3^0;
sbit   CLK=P3^1;
sbit   START=P3^2;
sbit   EOC=P3^3;
void  delay()///延时//
{
  uchar i;
  uchar j;
  for(i=0;i<=10;i++)
      for(j=0;j<=250;j++);
}
void   main()
{
     START=0;
  OE=0;
  ET0=1;
  ET1=1;
  EA=1;
  TMOD=0x12;//定时器T1工作1,定时器T0为工作2方式;
  TL0=216;
  TH0=216;
  TL1=(65536-4000)/256;
  TH1=(65536-4000)%256;
  TR1=1;
  TR0=1;
  START=1;
  START=0;
      while(1)
     {
         if(EOC==1)  //==A/D转换完成==//
         {
        OE=1; //允许取数据///
      getdata=P1;//取数据//
      OE=0;
      temp=getdata*500;
      temp=temp/256;
      dispbuf[0]=temp/100;
      dispbuf[1]=temp%100/10;
      dispbuf[2]=temp%100%10;
      START=1;
      START=0;
      }
     }
}
void t0(void) interrupt 1  using 0
{CLK=~CLK;}//时钟信号//
void t1(void) interrupt 3  using 0
{
      TL1=(65536-4000)/256;
      TH1=(65536-4000)%256; //重新装入//
   P2=0x01;
   P0=dispcode[dispbuf[0]];
   delay();
   P2=0x02;
   P0=dispcode[dispbuf[1]];
   delay();
   P2=0x04;
   P0=dispcode[dispbuf[2]];
   delay();
}

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
demaxiya 发表于 2012-11-23 09:45 | 显示全部楼层
CLK=~CLK改为CLK=!CLK试试 希望可以帮到你
您需要登录后才可以回帖 登录 | 注册

本版积分规则

6

主题

55

帖子

0

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