You build a project in Keil, and the following paragraph is the code of display.c:
# Contains? " at89x5 1.h "
# Contains? " PCF8563.h "
//# contains? " TG 12232.h "
# Definition? Key_Set? P2_2
# Definition? Key_Add? P2_ 1
# Definition? Key_Sub? P2_0
//# Definition? LCD_CS? P2_5
//# Definition? LCD_DATA? P2_6
//# Definition? Liquid crystal _CLK? P2_7
Invalid? key _ down();
Invalid? Display buffer (char? Location);
//void? LCD _ Display();
Not signed? Charles? LedTable[ 10]={0x3f,0x03,0x6d,0x67,0x53,0x76,0x7e,0x23,0x7f,0x 77 };
Bit? Status = 0;
Charles? set = 0;
Invalid? Master ()
{
Not signed? Charles? I,j,n = 2;
p 1 = 0;
TMOD = 0x 0 1;
TH0 = 0x4c
TL0 = 0x00
ET0 = 1;
EA = 1;
//? p 8563 _ init();
P2 = 0x ff;
P3 = 0x 02;
p 1 = led table[8];
//? while(n -)
for(I = 0; I & lt250; i++)
for(j = 0; j & lt6; j++)
{
Delay (10); ;
P3<& lt= 1;
If (P3==0x80)
P3 = 0x 02;
Delay (10);
}
Delay (5000);
//? LCD _ init();
//? set_lcd_position(0, 1); //Chinese characters are positioned at the left end of the uplink.
//? LCD _ display (0,0, "Welcome? Where to? Use! ”);
//? lcd_display( 1,0,"? Leo. Zheng? ”);
//? Delay (1000);
//? LCD _ send _ com(0x 0 1); //Clear
//? lcd_display(0,0," 20? /? /");
while( 1)
{
key _ down();
Displaybuffer (setting);
//? LCD _ Display();
}
}
Invalid? Time0_H()? Interrupt? 1
{
Static electricity Not signed? Charles? I = 0; ?
TH0 = 0x4c
TL0 = 0x00
i++;
If (i==8)
{?
I = 0;
state = ~ state
}
}?
/*
Invalid? Liquid crystal display ()
{
lcd_display_char(0,2,((g 8563 _ Store[6]& amp; 0xf0)>& gt4)+0x 30); //year
lcd_display_char(0,3,(g 8563 _ Store[6]& amp; 0x0f)+0x 30); //
}*/
Invalid? Down arrow ()
{
//? Static electricity Charles? set = 0;
Not signed? Charles? Buffer area;
If (! Key_Set)
for(buffer = 0; Buffer < 250; Buffer++)
_ nop _();
If (! Key_Set)
{
if(set==0)
{
writeData(0x0,0x 20); //Stop time?
TR0 = 1;
}
set++;
if(set==4)
{
set = 0;
TR0 = 0;
writeData(0x0,0x 00);
}
And (! Key_Set)
Displaybuffer (setting);
}
If (! Key_Add)
for(buffer = 0; Buffer < 250; Buffer++)
_ nop _();
If (! Key_Add)
{
if(set==0)
Return;
p 8563 _ gettime();
Buffer =? g 8563 _ Store[set- 1];
buffer =((buffer & amp; 0xf0)>& gt4)* 10+(buffer & amp; 0x0f);
if(buffer & gt; =59)
Buffer = 0;
Or what? if(buffer & gt; =23? & amp& amp? set==3)
Buffer = 0;
other
buffer++;
Buffer = (buffer/10 <; & lt4)+ (buffer%10);
writeData(set+ 1,buffer);
And (! Key_Add)
Displaybuffer (setting);
}
If (! Key_Sub)
for(buffer = 0; Buffer < 250; Buffer++)
_ nop _();
If (! Key_Sub)
{
if(set==0)
Return;
p 8563 _ gettime();
Buffer =? g 8563 _ Store[set- 1];
buffer =((buffer & amp; 0xf0)>& gt4)* 10+(buffer & amp; 0x0f);
If (buffer? ==? 0)
{
if(set==3)
Buffer = 23;
other
Buffer = 59;
}
other
Buffer-; ?
Buffer = (buffer/10 <; & lt4)+ (buffer%10);
writeData(set+ 1,buffer);
And (! Key_Sub)
Displaybuffer (setting);
}
}?
Invalid? Display buffer (char? Location)
{
Not signed? Charles? Me;
p 8563 _ gettime();
/*****************************************/
if(Location== 1? & amp& amp? Status ==0)
{?
p 1 = 0;
P3 = 0;
goto? sec _ bit 1;
}?
P3 = 0x 02; ?
p 1 = led table[g 8563 _ Store[0]& amp; 0x0f]; ? //sec
sec_bit 1:
for(I = 0; I & lt250; i++);
p 1 = 0; ?
if(Location== 1? & amp& amp? Status ==0)
{
p 1 = 0;
P3 = 0;
goto? sec _ bit2
}?
P3 = 0x 04;
p 1 = led table[(g 8563 _ Store[0]& amp; 0xf0)>& gt4];
sec_bit2:
for(I = 0; I & lt250; i++); ?
p 1 = 0;
/*****************************************/
if(Location==2? & amp& amp? Status ==0)
{?
p 1 = 0;
P3 = 0;
goto? min _ bit 1;
}?
P3 = 0x 08;
p 1 = led table[g 8563 _ Store[ 1]& amp; 0x0f]; ? //Minimum value
min_bit 1:
for(I = 0; I & lt250; i++); ?
p 1 = 0;
if(Location==2? & amp& amp? Status ==0)
{?
p 1 = 0;
P3 = 0;
goto? min _ bit2
}
P3 = 0x 10; ?
p 1 = led table[(g 8563 _ Store[ 1]& amp; 0xf0)>& gt4];
min_bit2:
for(I = 0; I & lt250; i++); ?
p 1 = 0;
/*****************************************/
if(Location==3? & amp& amp? Status ==0)
{?
p 1 = 0;
P3 = 0;
goto? hour _ bit 1;
}?
P3 = 0x 20;
p 1 = led table[g 8563 _ Store[2]& amp; 0x0f]; //hour
hour_bit 1:
for(I = 0; I & lt250; i++); ?
p 1 = 0;
if(Location==3? & amp& amp? Status ==0)
{?
p 1 = 0;
P3 = 0;
goto? hour _ bit2
}?
P3 = 0x 40;
p 1 = led table[(g 8563 _ Store[2]& amp; 0xf0)>& gt4];
hour_bit2:
for(I = 0; I & lt250; i++);
p 1 = 0;
P3 = 0x 02; ?
/*****************************************/
}
The following paragraph is the code of pcf8563.h:
#ifndef? __PFC8563_H__
# Definition? __PFC8563_H__
# Contains? & ltintrins.h & gt
# Definition? Ucal? Not signed? tea
sbit? sda=p2^4;
sbit? scl=p2^3;
//extern? Invalid? _nop_? (void);
//extern? Invalid? Delay (unsigned? int? ms);
Ucal? g 8563 _ Store[7]; ? /* Time exchange area, global variable declaration */
Ucal? Code? c8563_Store[7]={0x0 1,0x02,0x07,0x09,0x04,0x02,0x 12 }; ? /* Initial writing time: seconds, minutes, hours, days, weeks, months and years (BCD code)?
07:59:00*/
Invalid? Delay (long? Time)
{ while(time-);
}
/********************************************
Internal function, delay 1
********************************************/
Invalid? DD()
{
//delay( 1);
//? Ucal? Me;
//for(I = 0; I & lt250; i++)
_ nop _();
_ nop _(); ? /* Set the delay time according to the crystal frequency */
}
/********************************************
Internal function, I2C startup
********************************************/
Invalid? Start ()
{? EA = 0;
SDA = 1;
SCL = 1;
DD();
SDA = 0;
DD();
SCL = 0;
}
/********************************************
Internal function, I2C terminal
********************************************/
Invalid? Stop ()
{
SDA = 0;
SCL = 0;
DD();
SCL = 1;
DD();
SDA = 1;
DD();
EA = 1;
}
/********************************************
Internal function, output ACK? , every byte transmission is completed, output ack=0, and end reading data, ack =1;
********************************************/
Invalid? WriteACK(uchar? Confirm)
{
SDA = ack
DD();
SCL = 1;
DD();
SCL = 0;
}
/********************************************
Internal function, waiting for confirmation
********************************************/
Invalid? Weitak ()
{? Ucal? errtime = 20
SDA = 1;
DD(); ? /* Read confirmation */
SCL = 1;
DD();
while(SDA)
{? errtime-;
? If (! errtime)?
? {
stop();
SDA = 0; ? //I added * * * *
? }
}
SDA = 1; ? //I added * * * *
SCL = 0;
DD();
}
/********************************************
Intrinsic function. Output data byte
Entry: B= data
********************************************/
Invalid? writebyte(uchar? wdata)
{
Ucal? Me;
for(I = 0; I<8; i++)
{
if(wdata & amp; 0x80)? SDA = 1;
Or what? SDA = 0;
wdata & lt& lt= 1;
SCL = 1;
DD();
SCL = 0;
}
WaitACK(); ? //I2C device or communication error will exit I2C communication.
}
/********************************************
Intrinsic function. input data
Exit: b
********************************************/
Ucal? Read bytes ()
{
Ucal? Me, bytedata
SDA = 1;
for(I = 0; I<8; i++)
{
? SCL = 1; ?
? bytedata & lt& lt= 1;
? bytedata | = SDA
? SCL = 0;
? DD();
}
return(byte data);
}
/********************************************
Output data->; pcf8563
********************************************/
Invalid? writeData(uchar? Address, Ucha? mdata)
{
start();
write byte(0x a2); ? /* Write command */
Writebyte (address); ? /* Write address */
write byte(mdata); ? /* Write data */
stop();
}
/********************************************
input data
********************************************/
Ucal? ReadData(uchar? Address)? /* Single byte */
{? Ucal? rdata
start();
write byte(0x a2); ? /* Write command */
Writebyte (address); ? /* Write address */
start();
write byte(0x a3); ? /* Read command */
rdata = read byte();
WriteACK( 1);
stop();
return(rdata);
}
Invalid? ReadData 1(uchar? Address, Ucha? Count, Utchard? *? buff)? /* Multibyte */
{? Ucal? Me;
start();
write byte(0x a2); ? /* Write command */
Writebyte (address); ? /* Write address */
start();
write byte(0x a3); ? /* Read command */
for(I = 0; I < count; i++)
{
buff[I]= read byte();
What if (I & ltcount- 1)? write ack(0);
}
WriteACK( 1);
stop();
}
/********************************************
Internal function that reads time into the internal buffer.
********************************************/
Invalid? P8563_Read()
{ uchar? Time [7];
ReadData 1(0x02, 0x07, time);
g 8563 _ Store[0]= time[0]& amp; 0x7f? /* seconds */
g 8563 _ Store[ 1]= time[ 1]& amp; 0x7f? /* Integral */
g 8563 _ Store[2]= time[2]& amp; 0x3f? /* Hours */
g 8563 _ Store[3]= time[4]& amp; 0x07? /* Week */
g 8563 _ Store[4]= time[3]& amp; 0x3f? /* Day */
g 8563 _ Store[5]= time[5]& amp; 0x 1f; ? /* Month */
g 8563 _ Store[6]= time[6]; ? /* Year */
}
/********************************************
Read time into internal buffer-external call?
********************************************/
Invalid? P8563_gettime()
{
p 8563 _ Read();
if(g8563_Store[0]==0)
? p 8563 _ Read(); ? /* If it is seconds =0, read it again */
}
/********************************************
Write time modification value
********************************************/
//void? P8563_settime()
//{
// ? Ucal? Me;
// ? for(I = 2; I < = 8; i++)? {? writeData(i,g 8563 _ Store[I-2]); ? }
// ? writeData(6,g 8563 _ Store[3]);
//}
/********************************************
P8563 initialization-external call
********************************************/
/*
Invalid? P8563_init()
{
Ucal? Me;
if((read data(0xa)& amp; 0x3f)! =0x8)? //Check whether it is the first time to start, and if so, initialize the time.
{?
// ? for(I = 0; I < = 6; i++)? g 8563 _ Store[I]= c 8563 _ Store[I]; ? //Initialization time
// ? p 8563 _ settime();
writeData(0x0,0x 00);
writeData(0xa,0x 8); ? //Call the police at 8 o'clock
writeData(0x 1,0x 12); ? //The alarm is valid
writeData(0xd,0xf 0);
}
}
*/
#endif