#include <reg51.h>
#define uint unsigned int
#define uchar unsigned char
uint num,num1,num2,num3,num4,num5,num6; //numóÃà′
sbit dula=P2^6; //éùÃ÷¶ÎÑ¡μÄËø′æ¶Ë
sbit wela=P2^7; //éùÃ÷λѡμÄËø′æ¶Ë
uchar code table[]={ //12òõêyÂë1ü0-FμĶÔó|μÄ16½øÖÆ′úÂë
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71}
void delay(int z) //¾§Õñ12MhzÑóê±zoáÃëμÄÑóê±×ó3ìDò
{
int i,j;
for(i=z;i>0;i--)
for(j=110;j>0;j--);
}
void dislpay()
{
P0=0xff; //Ïûó°
wela=1; //′ò¿aλѡ¶Ë
P0=0xf7; //′ò¿aμúò»Î»êyÂë1ü
wela=0; //Ëø′æλѡDÅoÅ
P0=0xff;
dula=1;
P0=table[num6];
dula=0; //¶ÎÑ¡êy¾YËø′æ
delay(1);
P0=0xff; //Ïûó°
wela=1; //′ò¿aλѡ¶Ë
P0=0xfb; //′ò¿aμúò»Î»êyÂë1ü
wela=0; //Ëø′æλѡDÅoÅ
P0=0xff;
dula=1;
P0=table[num5];
dula=0; //¶ÎÑ¡êy¾YËø′æ
delay(1);
P0=0xff; //Ïûó°
wela=1; //′ò¿aλѡ¶Ë
P0=0xfd; //′ò¿aμúò»Î»êyÂë1ü
wela=0; //Ëø′æλѡDÅoÅ
P0=0xff;
dula=1;
P0=table[num4];
dula=0; //¶ÎÑ¡êy¾YËø′æ
delay(1);
P0=0xff; //Ïûó°
wela=1; //′ò¿aλѡ¶Ë
P0=0xfe; //′ò¿aμúò»Î»êyÂë1ü
wela=0; //Ëø′æλѡDÅoÅ
P0=0xff;
dula=1;
P0=table[num3];
dula=0; //¶ÎÑ¡êy¾YËø′æ
delay(1);
}
void T0_time interrupt 1
{
TH0=0x3C;
TL0=0xB0;
num++;
if(num==20) //ËμÃ÷1s¶¨ê±òÑμ½
{
num=0; //ÖÃ0£¬ÏÂ′ÎÖØD¼Æêy
num1++;
if(num1==60) //ËμÃ÷1·ÖÖó¶¨ê±òѾ-μ½
{
num1=0;
num2++;
if(num2==60) //ËμÃ÷ò»D¡ê±¶¨ê±μ½áË
num2=0;
num3=num2/10; //óÃà′ÏÔê¾·Öμĸß룬±èèç23·Ö£¬ÏÔê¾2
num4=num2%10; //óÃà′ÏÔê¾·ÖμÄμí룬±èèç23·Ö£¬ÏÔê¾3
}
num5=num1/10; //óÃà′ÏÔê¾Ãëμĸß룬±èèç23Ã룬ÏÔê¾2
num6=num1%10 //óÃà′ÏÔê¾ÃëμÄμí룬±èèç23Ã룬ÏÔê¾3
}
}
void init() //¶¨ê±ÖD¶Ï3õê¼»ˉ3ìDò
{
TMOD=0x01; //¶¨ê±Æ÷0£¬1¤×÷·½ê½116붨ê±/¼ÆêyÆ÷
TH0=0x3C; //éèÖÃ50ms¶¨ê±
TL0=0xB0;
ET0=1;
EA=1;
TR0=1;
}
void main()
{
init();
while(1)
{
display();
}
}
实验5.c(15): error C141: syntax error near 'for'
实验5.c(12): error C141: syntax error near 'void'
实验5.c(13): error C141: syntax error near '{' |