51利用定时器1计数模式,方式1让P2口加到200次清零

#include 
#include 
#define uchar unsigned char
 uchar count;
void main()
{
	EA = 1;
  ET1 = 1;
	TMOD = 0x50;
	TH1 = 0xffff;
  TL1 = 0xffff;
	TR1 = 1;
	P2=0;
	while(1)
	{
		
   P2=count;
  }
}

void Int1() interrupt 3
{
	
	TH1 = 0xffff;
  TL1 = 0xffff;
  count++;
	if(count>200)
	{
    count=0;
  }
	
}

你可能感兴趣的:(C语言,单片机)