Home > other >  Two pieces of 74 hc138 electronic clock design program MCU for help bosses give directions
Two pieces of 74 hc138 electronic clock design program MCU for help bosses give directions

Time:09-16

Simulation figure as follows, single-chip microcomputer system of electronic clock design for 12 hours, display the information as follows: - HHMM empty SS. S empty, among them - on behalf of the morning or afternoon, not bright in the morning and afternoon light - HH on behalf of the hour, MM on behalf of the minutes, seconds, SS on behalf of the integer s representing decimal seconds, empty said does not display, I am to change, according to eight engineering simulation requirements need 10, now the program does not know how, ask bosses,

CodePudding user response:

 # include 
# include "intrins. H"
# define uint unsigned int
# define uchar unsigned char

Sbit FMQ=P3 ^ 0;//?? U? Present??????

Char table []={xa4 xc0 0, 0 xf9, 0, 0, xb0 x99 0, 0 x92, 0 x82, 0 xf8, 0 x80, 0 x90, 0 XFF, 0 xc6, 0 xc7, 0 x88,};//12?????? Ey???? 1 u + a???? ? ° 0-9? Plus or minus
//0 1 2 3 4 5 6 7 8 9 2??????? E? C L A
Uchar val [8]=,0,0,0,0,0,11,12 {0};//ey???? 1 u?? E?? O3???

Uint count=0;//
Char shi=0, fen=0, miao=0;//e +??? Plus or minus? A?
Char nzshi=0, nzfen=0, nzmiao=0;//??? Oe +,??? Plus or minus? A?
Uchar wei=0 x01, duan=0;//?????? Ey???? 1 u?? Oi?????? E? Mu? Plus or minus? A?

Led (void)//ey???? 1 ue ¨? Eo ˉ ey
{
P0=0 XFF;
The P2=wei;
If ((duan==1) | | (duan==3))//? Aa? E?? OD? Ey mu? O? Mu?
{
P0=(table [val [duan]] & amp; 0 x7f);
}
The else
{
P0=table [val [duan]].
}

Duan++;
If (duan> 7)
Duan=0;
Wei=_crol_ (wei, 1);
}

Void time0init ()//? ¨ e +? Present 03? E?? ˉ
{
TMOD=0 x01;
TH0=(65536-2000)/256;
TL0=(65536-2000) % 256;
ET0=1;
TR0=1;
EA=1;
}

Uchar keytime=0;//?'? U
Uint bjtime=0;//+ ¨? ˉ?? E + +? A?
Bit SJBS=0;//?'? UA?????? E +?? X? I on mu? Plus or minus? A?
Void time0 () interrupt 1//? ¨ e +? Present 0? D?? T.?? O ˉ ey
{
TH0=(65536-2000)/256;
TL0=(65536-2000) % 256;
If (SJBS)
{
count++;
}
Bjtime++;
Keytime++;
Leds ();//2 mse ¨? Eo? '? Ey???? 1 u?? E?
}


Uchar key ()//?'? Ue ¨? E3iDo
{
The static uchar KZT=0;
Uchar sb=25;
The switch (KZT)
{
Case 0:
P1=0 XFF;
If (P1!=0 XFF)
{
KZT=1;
The return of 25;
}
break;
Case 1:
P1=0 XFF;
If (P1!=0 XFF)
{
The switch (P1)
{
Case 0 xfe:
Sb=1;
break;
Case 0 XFD:
Sb=2;
break;
Case 0 XFB:
Sb=3;
break;
Case 0 xf7:
Sb=4;
break;
Case 0 xef:
Sb=5;
break;
Case 0 XDF:
Sb=6;
break;
Case 0 XBF:
Sb=7;
break;
Case 0 x7f:
Sb=8;
break;
}
KZT=2;
Return sb.
}
The else
{
KZT=0;
The return of 25;
}
break;

Case 2:
P1=0 XFF;
If (P1==0 XFF)
{
KZT=0;
The return of 25;
}
break;
}
The return of 25;
}


Void sj ()//e +??????? E +??? UD?
{
If (count> 499)
{
Count=0;
Miao++;
If (miao> 59)
{
Miao=0;
Fen++;
If (fen> 59)
{
Fen=0;
Shi++;
If (shi> 23)
{
Shi=0;
}
}
}

}

}



Void main ()
{
Uchar keycode=25, zt=1;
Bit BJBS=0;
FMQ=1;
Time0init ();//3? E?? ˉ? ¨ e +? Present 0
While (1)
{
If (keytime> 9)//20 ms e ¨? Eo? '? ° '? U
{
Keytime=0;
Keycode=key ();
}

If (((fen==0) & amp; & (miao==0)) | | ((shi==nzshi) & amp; & (fen==nzfen) & amp; & (miao==nzmiao)))
{//? D?????? Mu? ? D?? E? Who? Mu?????? Oe +??
BJBS=1;
FMQ=0;
Bjtime=0;
}




If (BJBS)//+ ¨? ˉ '| ai
{
If (bjtime> 30000)
{
FMQ=1;
BJBS=0;
}
If ((keycode> 1) & amp; & (keycode<5))//?? Oa? U? U? De - mu present? U? Ii on? 1? U? D
{
BJBS=0;
FMQ=1;
}
}



The switch (zt)
{
Case 1://e +? O?? E?

Val [0]=shi/10;//?? E? Ey? Y? UD?
Val [1]=shi % 10;

Val [2]=fen/10;
Val [3]=10 fen %;

Val [4]=miao/10;
Val [5]=miao % 10;

Val [6]=11;
Val [7]=12;

If (keycode==1)//A to e +?????? DDo?? Yi on
{
SJBS=! SJBS;
Keycode=25;
}
Sj ();

If (keycode==2)//B??????? O1
{
Miao++;
If (miao> 59)
{
Miao=0;
}
Keycode=25;
}

If (keycode==3)//c.? ? O1
{
Fen++;
If (fen> 59)
{
Fen=0;
}
Keycode=25;
}

If (keycode==4)//D e +? O1
{
Shi++;
If (shi> 23)
{
Shi=0;
}
Keycode=25;
}

If (keycode==5)//E?? E?????? Oee?? X 'I?
{
Zt=2;
Keycode=25;
}

break;


Case 2://??????? O?? E? O? Mu present? U

Sj ();//e +??? UD?
Val [0]=nzshi/10;//?? E? Ey? Y? UD?
Val [1]=nzshi % 10;

Val [2]=nzfen/10;
Val [3]=nzfen % 10;

Val [4]=nzmiao/10;
Val [5]=nzmiao % 10;

Val [6]=13;
Val [7]=12;

If (keycode==2)//B??????? O??? O1
{
Nzmiao++;
If (nzmiao> 59)
{
Nzmiao=0;
}
Keycode=25;
}

If (keycode==3)//C??????? O.?? O1
{
Nzfen++;
If (nzfen> nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related