定时器计数器应用设计P1.0上产生周期为2ms的方波,基本思路:要在P1.0上产生周期为2ms的方波,定时器应产生1ms的周期性的定时,定时对P1.0求反。选择定时器T0,方式1定时,采用中断方式,GATE不起作用。
参考中断程序void T0_int(void) interrupt 1 using 0 { P1_0=! P1_0; TH0=(65536 1000) /256; TL0=(65536 1000) %256; }
定时器计数器应用设计P1.0上产生周期为2ms的方波,基本思路:要在P1.0上产生周期为2ms的方波,定时器应产生1ms的周期性的定时,定时对P1.0求反。选择定时器T0,方式1定时,采用中断方式,GATE不起作用。
参考中断程序void T0_int(void) interrupt 1 using 0 { P1_0=! P1_0; TH0=(65536 1000) /256; TL0=(65536 1000) %256; }