|
|
#include<reg52.h>
typedef unsigned char uint8;
typedef unsigned int uint16;
sbit t0=P3^4;
sbit led=P0^0;
sbit puls=P1^0;
void delay(uint16 i)
{
while(i--);
}
void jishu0()
{
TMOD=0x05; //選擇計數(shù)器模式,選擇定時器0,模式一
TH0=0xfc; //裝載計數(shù)器初值
TL0=0x18;
TR0=1;
ET0=1;
EA=1;
}
void main()
{
jishu0();
while(1)
{
puls=1;
delay(100);
puls=0;
delay(1);
}
}
void int0()interrupt 1
{
TH0=0xfc;
TL0=0x18;
led=~led;
}
|
|