以上就是中断的程序,今天又试了好久,依旧没有成功,请指点,谢谢~~~~
/****************************定时器0初始化***************************************************/ void Timer0_init()
{ TMOD=0x01; IE=0x82; TH0 = (65536-45872)/256; TL0 = (65536-45872)%256; TR0=1; }
/*****************************定时器0中断******定时关机***********************************************/ void Time0_Init() interrupt 1
{ TH0 = (65536-45872)/256; TL0 = (65536-45872)%256; Count1++;
if(Count1==20) { Count1=0; miao1--; if(miao1==-1) { fen1--; miao1=59;
if(fen1==-1) { shi1--; fen1=59;
if(shi1==0) { shi1=0;
} write_djs(1,shi1);
}
write_djs(3,fen1); }
write_djs(5,miao1); }
if(miao1==0&&fen1==0&&shi1==0&&m==1) { TR0=0; RELAY=0; //继电器关闭,电机关闭 } } /***************************定时器1初始化**********************************************************/ void Timer1_init()
{ TMOD=0x11; IE=0x88; TH1 = (65536-45872)/256; TL1 = (65536-45872)%256; TR1=1; } /*****************************定时1中断******定时开机***********************************************/ void Time1_Init() interrupt 3
{ TH1 = (65536-45872)/256; TL1 = (65536-45872)%256; Count2++;
if(Count2==20) { Count2=0; miao1--; if(miao1==-1) { fen1--; miao1=59;
if(fen1==-1) { shi1--; fen1=59;
if(shi1==0) { shi1=0;
} write_djs(1,shi1);
} write_djs(3,fen1); }
write_djs(5,miao1); }
if(miao1==0&&fen1==0&&shi1==0) { TR1=0; RELAY=1; //继电器工作,电机开启 } }
|