#includesbitpwm=P3^7;sbitjia=P3^0;sbitjian=P3^5;sbitled=P3^2;chartt0,zkb;voidinit();voidmain(){ init(); while(1) { if(jia) { ysms(80); if(jia) { zkb--; if(zkb8) { zkb=8; } while(jian); } } if(zkb==8) { TR0=0; pwm=1; } else { TR0=1; } }}voidinit(){ P3M1=0X21; //00100001P350SHURU TMOD=0X01; TH0=0XFF; //6MHZ100uS TL0=0XCE; ET0=1; EA=1; TR0=1; zkb=8; led=0; ysms(200); led=1; ysms(200); led=0; ysms(200); led=1; ysms(200); led=0; ysms(200); led=1; ysms(200); led=0;}voidtime0()interrupt1{ tt0++; if(tt0>zkb) { pwm=0; } if(tt0>8) { tt0=0; pwm=1; } TH0=0XFF; //6MHZ100uS TL0=0XCE;}
1