signed char dem,dem1;
unsigned char BDN,BDN1;
const unsigned char MA7D[10]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
//=============== DELAY 500ms ======================
void timer0_interrupt()interrupt 1
{
BDN++;
TL0=-50000;
TH0=-50000>>8;
if(BDN==10)
{ BDN=0;
dem++;
if(dem>99){dem=0;}
}
}
//============== DELAY 600ms =======================
void timer1_interrupt()interrupt 3
{
BDN1++;
TH1=-50000>>8;
TL1=-50000;
if(BDN1==12)
{
BDN1=0;
dem1--;
if(dem1<0){dem1=99;}
}
}
//====================================
void delay(unsigned int x)
{
unsigned int i ;
for(i=0;i<x;i++)
{
}
}
//====================================
void giaimahienthi()
{
P1=MA7D[dem%10] ;P2_4=0;delay(100);P2_4=1;
P1=MA7D[dem/10] ;P2_3=0;delay(100);P2_3=1;
P1=MA7D[dem1%10] ;P2_1=0;delay(100);P2_1=1;
P1=MA7D[dem1/10] ;P2_0=0;delay(100);P2_0=1;
}
//=====================================
void main()
{
TMOD=17;
IE=0x8A;
TH0=TH1=-50000>>8;
TL0=TL1=-50000;
TR0=TR1=1;
dem1=99;
dem=0;
while(1)
{
giaimahienthi();
}
}
Không có nhận xét nào:
Đăng nhận xét