Bootstrap

KEIL4编写51单片机定时器0 和定时器1

#include<reg52.h>
sbit led1 = P1^1;
sbit led0 = P1^0;

void main()
{
	unsigned char cnt = 0,cnt1=0;
	TMOD = 0x11;  
	TH1 = 0x3c;
	TL1 = 0xb0; 
	TR1 = 1; 
	
	TH0= 0x3c;
	TL0 = 0xb0; 
	TR0 = 1;
	while(1)
	{
		if(TF1 == 1)
		{
			TF1 = 0;
			TH1 = 0x3c;
			TL1 = 0xb0;
		 	cnt++;
		 	if(cnt == 20)
		 	{
		 		cnt = 0;
			led1 = ~led1;
		 	}
		}
		
		if(TF0==1)
		{
				TF0 = 0;
			TH0 = 0x3c;
			TL0 = 0xb0;
		 	cnt1++;
		 	if(cnt1 == 20)
		 	{
		 		cnt1 = 0;
				led0 = ~led0;
		}
	}
}
}

;