2020年6月8日 星期一

66-99

#include <at89x52.h>
char seg_7_table[]={0xc0,0xf9,0xb0,0xa4,0x99,0x92,0x82,0xf8,0x80,0x90};
char scan_line[]={0xfe,0xfd};
char bcd[]={6,6};
int count=66;
int time=20,j;
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=seg_7_table[bcd[j]];
P2=scan_line[j];
j++;
if(j==2)
{
j=0;
}
}
void T1_int(void) interrupt 3
{
TH1=(65536-50000)/256;
TL1=(65536-50000)%256;
  time--;
if(time==0)
{
time=20;
count++;
if(count>99)
{
count=66;
}
bcd[0]=count%10;
bcd[1]=count /10;
}
}

沒有留言:

張貼留言

algorithm

 #include <iostream> #include <string.h> using namespace std; int main(int argc, char** argv)  { for(int j=2;j<=100;j++)//j...