void kkimer_init(void)
{
EA=1;
ET2 = 1; //允许定时器0中断
TMOD |=0X10 ;
}
void FreqOut(unsigned int Freq)
{
kkime = 256 - (500000/Freq);
TH2 = 0XFF ;
TL2 = kkime ;
TR2 = 1;
delay_nus(800);
TR2 = 0;
}
void kkimer0_Interrupt(void) interrupt 5
{
P1_2 = ~P1_2;
P2_2=~P2_2;
TH2 = 0XFF;
TL2 = kkime;
} |