|
- #include<reg52.h>
- #include <intrins.h>
- typedef unsigned int a1;
- typedef unsigned char b2;
- unsigned char code DuanMa[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
- unsigned char Dis_dat[];
- unsigned char sec=00;
- void delay(a1 i)
- {
- while(i--);
- }
- void DisplaySMGwei(b2 pos)
- {
- P2=(P2&0x1f)|0xc0;
- P0=0x01<<pos;
- }
- void DisplaySMGdat(b2 dat)
- {
- P2=(P2&0x1f)|0xe0;
- P0=dat;
- }
- void datapros()
- {
- if(sec<60)
- {
- sec++;
- }
- else
- {
- sec=00;
- }
- Dis_dat[0]=DuanMa[sec/10];
- Dis_dat[1]=DuanMa[sec%10];
- }
- void SMG_Dynamic()
- {
- b2 i;
- for(i=0;i<2;i++)
- {
- switch(i)
- {
- case 0:DisplaySMGwei(0);break;
- case 1:DisplaySMGwei(1);break;
- }
- DisplaySMGdat(Dis_dat[i]);
- delay(500);
- }
- }
- void Delay100ms() //@12.000MHz
- {
- unsigned char i, j, k;
- _nop_();
- _nop_();
- i = 5;
- j = 144;
- k = 71;
- do
- {
- do
- {
- while (--k);
- } while (--j);
- } while (--i);
- }
- void main()
- {
- a1 x=50;
- while(1)
- {
- datapros();
- Delay100ms();
- while(x--)
- {
- SMG_Dynamic();
- }
- }
- }
復(fù)制代碼 |
|