01.c(31): warning C206: 'initlcd': missing function-prototype
01.c(63): error C216: subscript on non-array or too many dimensions
01.c(165): error C236: 'delay': different length of parameter lists
#include <reg52.h>
#include <intrins.h>
sbit RS=P2^0;
sbit RW=P2^1;
sbit E=P1^2;
sbit T_RST=P1^3;
sbit T_CLK=P1^7;
sbit T_IO=P2^3;
sbit s7=P3^0;
sbit s6=P3^1;
sbit s5=P3^2;
sbit s4=P3^3;
unsigned char TIME;
void Int0Configuration();
void LcdDisplay();
unsigned char SetState,SetPlace;
void delay(void);
unsigned char datechar[]={"DATE:"};
unsigned char timechar[]={"TIME:"};
unsigned char datebuffer[10]={0x32,0x30,0,0,0x2d,0,0,0x2d,0,0};
unsigned char timebuffer[8]={0,0,0x3a,0,0,0x3a,0,0};
unsigned char weekbuffer={0x30};
void main()
{
unsigned char i;
Int0Configuration();
initlcd();
//Ds1302Init();
while(1)
{
if(SetState==0)
{
unsigned char R1302(unsigned char address);
}
else
{
if(s6==0)
{
delay();
if(s6==0)
{
SetPlace++;
if(SetPlace>=7)
SetPlace=0;
}
while((i<50)&&(s6==0))
{
delay();
i++;
}
i=0;
}
if(s5==0)
{
delay();
if(s5==0)
{
TIME[SetPlace]++;
if((TIME[SetPlace]&0x0f)>9)
{
TIME[SetPlace]=TIME[SetPlace]+6;
}
if((TIME[SetPlace]>=0x60)&&(SetPlace<2))
{
TIME[SetPlace]=0;
}
if((TIME[SetPlace]>=0x24)&&(SetPlace==2))
{
TIME[SetPlace]=0;
}
if((TIME[SetPlace]>=0x32)&&(SetPlace==3))
{
TIME[SetPlace]=0;
}
if((TIME[SetPlace]>=0x13)&&(SetPlace==4))
{
TIME[SetPlace]=0;
}
if((TIME[SetPlace]>=0x7)&&(SetPlace==5))
{
TIME[SetPlace]=1;
}
// if(SetPlace==5)
// {
// TIME[SetPlace]=;
// }
}
while((i<50)&&(s5==0))
{
delay();
i++;
}
i=0;
}
}
LcdDisplay();
}
}
void WriteB(unsigned char dat)
{
unsigned char i;
for(i=8; i>0; i--)
{
T_IO=dat&0x01;
T_CLK = 1;
T_CLK = 0;
dat = dat >> 1;
}
}
unsigned char ReadB(void)
{
unsigned char i,readdat=0;
for(i=8; i>0; i--)
{
readdat=readdat>>1;
if(T_IO)
{
readdat|=0x80;
}
T_CLK = 1;
T_CLK = 0;
}
return(readdat);
}
void W1302(unsigned char address,unsigned char dat)
{
T_RST = 0;
T_CLK = 0;
_nop_();
_nop_();
T_RST = 1;
_nop_();
_nop_();
WriteB(address);
WriteB(dat);
T_CLK = 1;
T_RST =0;
}
unsigned char R1302(unsigned char address)
{
unsigned char dat=0;
T_RST = 0;
T_CLK = 0;
T_RST = 1;
WriteB(address);
dat = ReadB();
T_CLK = 1;
T_RST =0;
return(dat);
}
void delay(unsigned int n)
{
unsigned i=0,j=0;
for(i=0;i<n;i++)
{
for(j=0;j<120;j++);
}
}
void writedat(unsigned char dat)
{
RS=1;
RW=0;
E=0;
P0=dat;
delay();
E=1;
E=0;
}
void writecom(unsigned char com)
{
RS=0;
RW=0;
E=0;
P0=com;
delay();
E=1;
E=0;
}
void initlcd()
{
writecom(0x38);
writecom(0x0c);
writecom(0x06);
writecom(0x01);
}
void LcdDisplay()
{
LcdWriteCom(0x80+0X40);
LcdWriteData('0'+TIME[2]/16);
LcdWriteData('0'+(TIME[2]&0x0f));
LcdWriteData('-');
LcdWriteData('0'+TIME[1]/16);
LcdWriteData('0'+(TIME[1]&0x0f));
LcdWriteData('-');
LcdWriteData('0'+TIME[0]/16);
LcdWriteData('0'+(TIME[0]&0x0f));
LcdWriteCom(0x80);
LcdWriteData('2');
LcdWriteData('0');
LcdWriteData('0'+TIME[6]/16);
LcdWriteData('0'+(TIME[6]&0x0f));
LcdWriteData('-');
LcdWriteData('0'+TIME[4]/16);
LcdWriteData('0'+(TIME[4]&0x0f));
LcdWriteData('-');
LcdWriteData('0'+TIME[3]/16);
LcdWriteData('0'+(TIME[3]&0x0f));
LcdWriteCom(0x8D);
LcdWriteData('0'+(TIME[5]&0x07));
}
void Int0Configuration()
{
//éèÖÃINT0
IT0=1;
EX0=1;
EA=1;
}
//********************************
void Int0() interrupt 0
{
delay(10);
if(s7==0)
{
SetState=~SetState;
SetPlace=0;
Ds1302Init();
}
}
|