51单片机fosc=11.0592MHz,T0采用定时方式1,从P1.0生成1KHz方波,要求定时初值精确计算。c语言程序如下实现对否? //从P1.0口输出1khz的方波 #include"reg52.h" #define fosc 11.0592 //晶振频率11.0592mhz #define time0 500 //定时500us #define adj 7 //精确定时 sbit clk=P1^0; unsigned char time0_h,time0_l; unsigned int time0_times; void main(void) { TMOD=(TMOD&0xf0)|0x01; //先保护tmod,再设置t0定时方式1 time0_times=-time0*fosc/12+adj; time0_h=(time0_times/256); time0_l=(time0_times%256); TH0=time0_h;TL0=time0_l; EA=1;ET0=1;TR0=1;while(1) {PCON=0x01;}} //定时器0(t/c 0)中断服务程序 void timer0_int(void) interrupt 1 {clk=~clk;//汇编cpl a,1T机器 TH0=time0_h; //汇编mov,2T机器 TL0=time0_l; //汇编mov,2T机器 } //中断返回汇编指令reti,2T机器