第2个回答 2013-01-05
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
uchar i,Second_Counts;
uchar DSY_CODE[]=
{
0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f
};
void DelayMS(uint ms)
{
uchar t;
while(ms--)
{
for(t=0;t<120;t++);
}
}
void main()
{
P0 = 0x3f;
i = 0;
Second_Counts = 0;
TMOD = 0x01;
TH0 = (65535-50000)/256;
TL0 = (65535-50000)%256;
while(1)
{
}
}
void DSY_Refresh() interrupt 1
{
TH0 = (65535-50000)/256;
TL0 = (65535-50000)%256;
if(++i==20)
{
i = 0;
P0 = DSY_CODE[Second_Counts++];
if(Second_Counts == 10) Second_Counts = 0;
}
}