這是一個c51編程單片機12mhz定時0.5秒程式,
#include<reg51.h>
char i=100;
void main()
{
TMOD=0x01;
TH0=0x78;
TL0=0xec;
EA=1;
P1=0X00;
ET0=1; //這是進入中斷,然后中斷回傳再執行下一步嗎?
TR0=1; //這里定時器啟動才開始將0x78ec輸入進行定時嗎?
while(1); //這里不是應該停在這里了?怎么回圈的
{
;
}
}
void timer0() interrupt 1
{
TH0=0xec;
TL0=0x78;
i--;
if(i<0)
{
P1=~P1;
i=100;
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/41221.html
標籤:非技術區
上一篇:計算1977!
