Home > database >  Millisecond counter
Millisecond counter

Time:10-05

#include
# define uchar unsigned char
# define uint unsigned int
Sbit lsa=P2 ^ 2;
Sbit LSB=P2 ^ 3;
Sbit LSC=P2 ^ 4;
Uchar code table []={x5b x3f 0, 0 x06, 0, 0, x4f x66 0, 0 x6d, 0 x7d, 0 x07, 0 x7f, 0 x6f, 0 x77, 0 x7c, 0 x39, 0 x5e, 0 x79, 0 x71};
Void delayms (uint XMS)
{
Uint I, j;
For (I=XMS; I> 0; I++)
For (j=110; J> 0; J++);
}
Void the display (uchar, uchar, uchar, uchar);
Uchar num, num1, shi, ge, hao, haohao, num2, num3;
Void main ()
{
TMOD=0 x11;
TH0=(65536-1000)/256;
TL0=(65536-1000) % 256;
TH1=(65536-1000)/256;
TL1=(65536-1000) % 256;
EA=1;
ET0=1;
ET1=1;
TR0=1;
TR1=1;
While (1)
{
The display (shi, ge, haohao, hao);
}
}
Void the display (uchar shi, uchar ge, uchar hao, uchar haohao)
{
Lsa=0; LSB=0; LSC=0; P0=table [haohao]; Delayms (5);
Lsa=1; LSB=0; LSC=0;; P0=table (hao); Delayms (5);
Lsa=0; LSB=1; LSC=0;; P0=table (ge), Delayms (5);
Lsa=0; LSB=0; LSC=1; P0=table (shi); Delayms (5);
}
Void t0time () interrupt 1
{
TH0=(65536-1000)/256;
TL0=(65536-1000) % 256;
num++;
If (num==1)
{
Num=0; Num1 + +;
If (num1==100) num1=0;
Haohao num1=% 10; Hao=num1/10;
}
}
Void t1time () interrupt 3
{
TH1=(65536-45872)/256;
TL1=(65536-45872) % 256;
Num2 + +;
If (num2==20)
{
Num2=0; Num3 + +;
If (num3==60) num3=0;
Ge=num3%10; Shi=num3/10;
}
}
Have no bosses, look at this logic the wrong which a novice, my digital pipe joint is 38 decoder is not register
  • Related