void Timer0Interrupt(void) interrupt 1 using 1 { TF0 =0;//-------------------------Clear the flag of timer0 TH0=(T0InitBuf&0xFF00)>>8;//-------get the THO TL0=T0InitBuf&0x00FF;//------------get the TL0 if(DelayCnt<250) DelayCnt++; else DelayCnt=0; if(DelayCnt%500==0){ NewData = InputPort; //采集输入端数据 } TimerFlag=1; }
上面是我的定时器程序,InputPort定义的是单片机的P1口,定时采集P1口的数据赋给NewData.这样子行不行? |