航天航天工业学院设计
程序
4.3程序功能:
#include
unsigned int msecond,second; bit flag; char hao,miao; unsigned
char
duan[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
char
duan2[]={0xbf,0x86,0xdb,0xcf,0xe6,0xed,0xfd,0x87,0xff,0xef};
//unsigned char code wei[]={0,1,2,3,4,5,6,7}; sbit p20=P2^0; sbit p21=P2^1; sbit p22=P2^2; sbit p23=P2^3;
unsigned char fen[8]; void delay(int z) {
while(--z); }
12
code
code
航天航天工业学院设计
void Init_Timer0(void);
void main (void) {
unsigned char num=0;
EX0=1; IT0=1; EX1=1; IT1=1; Init_Timer0(); while (1) {
fen[0]=duan[hao/10]; fen[1]=duan[hao]; fen[3]=duan[miao/10]; fen[4]=duan2[miao];
P0=0; P2=0xfe;
13
航天航天工业学院设计
P0=fen[3];
delay(200);
P2=0xfd; P0=fen[4]; delay(200); P2=0xfb; P0=fen[0]; delay(200); P2=0xf7; P0=fen[1];
delay(200);
} }
void Init_Timer0() {
TMOD |= 0x01; EA=1; ET0=1; TR0=1; }
14
航天航天工业学院设计
void Timer0() interrupt 1 {
unsigned char num; TH0=(65536-2000)/256; TL0=(65536-2000)%6; if(flag) { num++; if(num==5) { num=0; hao++; if (hao==100) { hao=0; miao++; if(miao==100) miao=0; } } }
15