#include <reg52.h>
 #define uint unsigned int
 #define uchar unsigned char
 sbit lw=P3^1;
 sbit ld=P3^0;
 uchar duan[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
 uchar wei[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
 uint hour=0,minute=0,second=0,t02ms=0;
 void delay()
 {
    uint i=30;
    while(i--);
    }
 void INT_init()
 {
    EA=1;
    TR1=1;
    ET1=1;
    TMOD=0x20;
    TH1=256-200;
    TL1=256-200;
 }
 /* ************************************************************************************ */
 main()
 {
    uchar i;
    INT_init();
    while(1)
    {
       for(i=0;i<=7;i++)
       {
      lw=1;
      P1=wei[i];
      lw=0;
      ld=1;
      switch(i)
      {
         case 0:P2=duan[hour/10];break;
        case 1:P2=duan[hour%10];break;
           case 2:P2=0xbf;break;
               case 3:P2=duan[minute/10];break;
        case 4:P2=duan[minute%10];break;
           case 5:P2=0xbf;break;
               case 6:P2=duan[second/10];break;
        case 7:P2=duan[second%10];break;
           default:break;
         }
         delay();
      }
       }
   }
   /* ************************************************************************************ */
void zxf() interrupt 3
  {
     t02ms++;
     if(t02ms==5000)
     {
    t02ms=0;
    second++;
    if(second==60)
    {
       second=0;
       minute++;
       if(minute==60)
       {
          minute=0;
          hour++;
          if(hour==60)
         hour=0;
          }
       
       }
    }
     
     }