void Timer1Mode3Init()
{
TH1 = 0xF8; //(65536 - 2000) / 256; set 2ms interrupt
TL1 = 0x30; //(65536 - 2000) % 256;
ET1 = 1; //timer1 overflow interrupt
TMOD |= 0x10 ; // timer1,mode 3
TR1 = 1; // timer 1 start
}
//==================================================================================
//
// name : Timer1 Interrupt
//
// function :
// -
//
//==================================================================================
void timer1(void) interrupt 3 //Timer1 interrupt 3
{
ET1 = 0;
TH1 = 0xF8; //(65536 - 2000) / 256; set 2ms interrupt
TL1 = 0x30; //(65536 - 2000) % 256;
LEDCount++;
ET1 = 1;
}
在中斷里面沒有重新設(shè)置裝載TH1 TL1的值,在時間上進(jìn)入的中斷時間差33倍,為66ms,有點嚇人。
標(biāo)題名稱:單片機timer-創(chuàng)新互聯(lián)
URL鏈接:http://chinadenli.net/article2/cdgpoc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供虛擬主機、外貿(mào)建站、用戶體驗、標(biāo)簽優(yōu)化、網(wǎng)頁設(shè)計公司、做網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容