补发下代码
#include <REG52.H>
#include <stdio.h> //Keil library
#include <INTRINS.H>
#define FSCLK 11059200
typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned int uint;
uint num = 1,flag = 1,time = 0;
sbit led1=P1^2;
sbit led2=P1^4;
void times(int num);
void Delay_ms(uint time)
{
uint i,j;
for(i = 0;i < time;i ++)
for(j = 0;j < 930;j ++);
}
void main()
{
while(1)
{
led1 = 0;
led2 = 0;
times(1);
led2 = 1;
led1 = 1;
times(1);
}
}
void time0()interrupt 1
{
TMOD = 0X01;
TH0 = (65536-FSCLK/12/20)/256;
TL0 = (65536-FSCLK/12/20)%256;
ET0 = 1;
EA = 1;
time ++;
if(time == 10)
{
time = 0;
flag = 1;
}
}
void times(uint num)
{
while(num!=0)
{
TR0 = 1;
if(flag!=0)
{
num--;
flag = 0;
TR0 = 0;
}
}
} |