#include "REG51.h"
int i=20;
int j=0;
char count=0;
char bcd[2]={0,0};
static const char table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
static const char P2table[]={1,2};
void main()
{
IE=0x8a;
TMOD=0x10;
TH0=(8192-5000)/32;
TL0=(8192-5000)%32;
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
TR0=1;
TR1=1;
while(1);
}
void T0_int(void) interrupt 1
{
TH0=(8192-5000)/32;
TL0=(8192-5000)%32;
P1=table[ bcd[j] ];
P2=~P2table[j];
j++;
if(j==2)
j=0;
}
void T1_int(void) interrupt 3
{
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
i = i-1;
if(i==0)
{
i=20;
count++;
if(count==100)
count=0;
bcd[1]=count/10;
bcd[0]=count%10;
}
}
沒有留言:
張貼留言