回覆列表
-
1 # 小紅的甜心
-
2 # 使用者3916807372217
#include
void InitTimer0(void)
{
TMOD = 0x01;//
TH0 = 0x0FC;//1MS延時
TL0 = 0x18;
EA = 1;
ET0 = 1;
TR0 = 1;
}
void main(void)
{
InitTimer0();
while(1);
}
void Timer0Interrupt(void) interrupt 1
{
TH0 = 0x0FC;
TL0 = 0x18;
P1=~P1;//點亮P1 1MS 週期2MS 500HZ
}
#include <reg51.h>//12M晶振
void InitTimer0(void)
{
TMOD = 0x01;//
TH0 = 0x0FC;//1MS延時
TL0 = 0x18;
EA = 1;
ET0 = 1;
TR0 = 1;
}
void main(void)
{
InitTimer0();
while(1);
}
void Timer0Interrupt(void) interrupt 1
{
TH0 = 0x0FC;
TL0 = 0x18;
P1=~P1;//點亮P1 1MS 週期2MS 500HZ
}