#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit speaker=P1^7;
uchar cnt750hz,cnt500hz;
uint cnt;
bit flag;
void main()
{
TMOD=0x02;
TH0 =0x06;
TL0 =0x06;
EA =1;
ET0=1;
TR0=0;
EX0=1;
IT0=1;
while(1)
{}
}
void t0() interrupt 1
{
cnt++;
if(cnt==2000)
{
cnt=0;
if(flag==0)
flag=~flag;
else
TR0=0;
}
if(flag==0)
{
cnt750hz++;
if(cnt750hz==3)
{
cnt750hz=0;
speaker=~speaker;
}
}
if(flag==1)
{
cnt500hz++;
if(cnt500hz==4)
{
cnt500hz=0;
speaker=~speaker;
}
}
}
void int0() interrupt 0
{
TR0=1;
}