typedef unsigned int u16; typedef unsigned char u8;
sbit LSA=P2^2; sbit LSB=P2^3; sbit LSC=P2^4;
sbit begin =P3^1; sbit stop =P3^2; sbit reset =P3^3;
u8 code smgduan[17]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07, 0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
u8 code table1[10]={0xbf,0x86,0xdb,0xcf,0xe6, 0xed,0xfd,0x87,0xff,0xef};
u8 ssec,sec,min;
u8 DisplayData[4];
void delay(u16 i) { while(i--); }
void Timer0Init() { TMOD|=0X01;
TH0=0Xd8; //10ms TL0=0Xf0; ET0=1; EA=1; TR0=0; }
void DigDisplay() { u8 i; for(i=0;i<4;i++) { switch(i) { case(0): LSA=1;LSB=1;LSC=1; break; case(1): LSA=0;LSB=1;LSC=1; break; case(2): LSA=1;LSB=0;LSC=1; break; case(3): LSA=0;LSB=0;LSC=1; break;
} P0=DisplayData[i]; delay(100); P0=0x00; } }
void datapros() { DisplayData[0]=smgduan[min/10]; DisplayData[1]=table1[min%10]; DisplayData[2]=smgduan[sec/10]; DisplayData[3]=smgduan[sec% 10];
}
void main() { Timer0Init(); while(1) {
if(begin==0) delay(1000); { if(begin==0) { TR0=1; while(!begin); } }
if(stop==0) delay(1000); { if(stop==0) { TR0=0; while(! stop); } }
if(reset==0) { delay(1000); if(reset==0) { TR0=0; sec=0; min=0; ssec=0; while(!reset); } }
datapros(); DigDisplay(); } }
void Timer0() interrupt 1 { TH0=0Xd8; TL0=0Xf0; ssec++; if(ssec>=100) { ssec=0; sec++; if(sec>=60) { sec=0; min++;
if(min>=60) { ssec=0; sec=0; min=0; } } } }
All reference designs on this site are sourced from major semiconductor manufacturers or collected online for learning and research. The copyright belongs to the semiconductor manufacturer or the original author. If you believe that the reference design of this site infringes upon your relevant rights and interests, please send us a rights notice. As a neutral platform service provider, we will take measures to delete the relevant content in accordance with relevant laws after receiving the relevant notice from the rights holder. Please send relevant notifications to email: bbs_service@eeworld.com.cn.
It is your responsibility to test the circuit yourself and determine its suitability for you. EEWorld will not be liable for direct, indirect, special, incidental, consequential or punitive damages arising from any cause or anything connected to any reference design used.
Supported by EEWorld Datasheet