附上代码:求帮助!!!
#include<stc15f2k60s2.h>
#include "iic.h"
#include "ds1302.h"
#include "onewire.h"
#include "intrins.h"
extern uchar shijian[7];
uchar code tab[]={0XC0,0XF9,0XA4,0XB0,0X99,0X92,0X82,0XF8,0X80,0X90,0XBF,0XFF,0XC6,0X89};
uchar digcom,wendu,shidu,jiejin,light;
uchar digbuf[]={11,11,11,11,11,11,11,11};
uchar S4,S5,flag;
void delayms(int ms);
void keyscan(void);
void Timer0Init(void);
void display(void);
void main(void)
{
P0=0XFF;P2=0X80;P0=0XFF;P2=0;
P0=0X00;P2=0XA0;P0=0X00;P2=0;
Tempget();
delayms(750);
Timer0Init();
DS_init();
while(1)
{
DS_get();
keyscan();
shidu=AD_read(0X03)/2.57;
wendu=Tempget();
if(S5==0)
{
digbuf[0]=wendu%100/10;digbuf[1]=wendu%10;digbuf[2]=12;digbuf[3]=11;digbuf[4]=11;digbuf[5]=shidu/10;digbuf[6]=shidu%10;digbuf[7]=13;
}
else if(S5==1)
{
digbuf[0]=shijian[2]/10;digbuf[1]=shijian[2]%10;digbuf[3]=shijian[1]/10;digbuf[4]=shijian[1]%10;digbuf[6]=shijian[0]/10;digbuf[7]=shijian[0]%10;
if(shijian[0]%2==0)
{
digbuf[2]=10;digbuf[5]=10;
}
else
{
digbuf[2]=11;digbuf[5]=11;
}
}
else if(S5==2)
{
digbuf[0]=11;digbuf[1]=11;digbuf[2]=11;digbuf[3]=10;digbuf[4]=0;digbuf[5]=0;digbuf[6]=0;digbuf[7]=0;
}
}
}
void keyscan(void)
{
if(P32==0)
{
delayms(5);
if(P32==0)
{
if(S5==0){S5=1;}
else if(S5==1){S5=2;}
else if(S5==2){S5=0;}
}
while(!P32);
}
if(P33==0)
{
delayms(5);
if(P33==0)
{
if(S4==0){S4=1;}
else if(S4==1){S4=0;}
}
while(!P33);
}
}
void Timer0Init(void) //1毫秒@11.0592MHz
{
AUXR |= 0x80; //定时器时钟1T模式
TMOD &= 0xF0; //设置定时器模式
TL0 = 0x9A; //设置定时初值
TH0 = 0xA9; //设置定时初值
TF0 = 0; //清除TF0标志
TR0 = 1; //定时器0开始计时
EA=1;
ET0=1;
}
void tm0_isr() interrupt 1
{
display();
}
void display(void)
{
P2=(P2&0X1F)|0XE0;
P0=0XFF;
P2&=0X1F;
P2=(P2&0X1F)|0XC0;
P0=1<<digcom;
P2&=0X1F;
P2=(P2&0X1F)|0XE0;
P0=tab[digbuf[digcom]];
P2&=0X1F;
if(++digcom==8)digcom=0;
}
void delayms(int ms)
{
int i,j;
for(i=0;i<ms;i++)
for(j=845;j>0;j--);
}
|