51单片机:使用晶振频率为6MHz作为时钟源,定时器T0工作在方式1,编程实现:P1.1引脚上输出周期为200ms的等宽正方波连续脉冲信号,要求以中断方式完成。

#include <reg52.h>	
sbit P11=P1^1; 	
void main( )
{
			TMOD = 0x01;			
TH0=(65536-10000)/256;			
TL0=(65536-10000)%256; 
			TR0=1; 			
			while(1);
}
void InterruptTimer0( ) interrupt 1
{
		static unsigned char count = 0; 
		TH0=(65536-10000)/256;
		TL0=(65536-10000)%256;
if(count<10)
{
			count++;	 
}
else
{
			count =0; 	
			P11=~P11; 	
}
}


版权声明:本文为aa543928678原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。