用TIMER0定波形的周期(高电平时间+低电平时间),用TIMER1定高电平的时间,用中断方式,帮我看看程序那里有问题? 波形从P1.7输出.
#include<reg52.h> #define uint unsigned int sbit P1_7=P1^7; uint count0; uint count1; void inter0()interrupt 1 /*timer0*/ { count0++; if(count0==10000) { P1_7=1; TR1=1; } TR0=1; } void inter1()interrupt 3 /*timer1*/ { count1++; if(count1==5000) { P1_7=0; } TR1=1; } void main() { TMOD=0X22; TR0=1; TR1=0; EA=1; ET1=1; ET0=1; TH1=-1000/256; TL1=-1000%256; TH0=-1000/256; TL0=-1000%256; P1_7=0; while(1); } |