#include <REG52.H>
#include <stdio.H>
#include <math.H>
#include <string.H>
unsigned char M[]={0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90};
unsigned char s1, s2;
unsigned int f, dem;
void delay (void)
{
unsigned int i;
for (i=1; i<=500; ++i);
}
void hienthi (void)
{
s1=f/10;
s2=f%10;
while(1)
{
P1=0xF2;
P0=M[s1];
delay();
P1=0xF1;
P2=M[s2];
delay();
}
}
void main (void)
{
TMOD = 0x25;
IE = 0x88;
IP = 0x08;
TH0 = TL0 = 0;
TH1 = TL1 = 5;
dem = 0; f = 0;
while (1)
{
TR1 = TR0 =1;
while (dem == 4000)
{
f = TH0 + TL0;
hienthi();
}
}
}
void ngatT1 (void) interrupt 3
{
++dem;
TF1 = 0;
TR1 =1;
}
#include <stdio.H>
#include <math.H>
#include <string.H>
unsigned char M[]={0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90};
unsigned char s1, s2;
unsigned int f, dem;
void delay (void)
{
unsigned int i;
for (i=1; i<=500; ++i);
}
void hienthi (void)
{
s1=f/10;
s2=f%10;
while(1)
{
P1=0xF2;
P0=M[s1];
delay();
P1=0xF1;
P2=M[s2];
delay();
}
}
void main (void)
{
TMOD = 0x25;
IE = 0x88;
IP = 0x08;
TH0 = TL0 = 0;
TH1 = TL1 = 5;
dem = 0; f = 0;
while (1)
{
TR1 = TR0 =1;
while (dem == 4000)
{
f = TH0 + TL0;
hienthi();
}
}
}
void ngatT1 (void) interrupt 3
{
++dem;
TF1 = 0;
TR1 =1;
}
Comment