新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > HOLTEK ht67f50單片機timer0定時

HOLTEK ht67f50單片機timer0定時

作者: 時間:2016-11-25 來源:網(wǎng)絡(luò) 收藏
1.HOLTEK該款單片機還是很不錯的,功能基本齊全,就是沒有uart,讓我很頭疼,不過其他的性能不錯,尤其是定時器功能可所謂一應(yīng)俱全。

下面是我實驗timer0的基礎(chǔ)定時,按照數(shù)據(jù)手冊上的來弄是很簡單的:

本文引用地址:http://butianyuan.cn/article/201611/321285.htm

#include "HT67F50.h"
#pragma vector isr_14 @ 0x24//時基中斷服務(wù)程序 修改

#define Loud _1d_5 //蜂鳴器定義 PB5修改

unsigned long count;

void initial() //IO初始化
{

// _intc1 = 0x02; //關(guān)閉時基中斷
// _intc0 = 0x01;//允許全局中斷和定時器0中斷


//**蜂鳴器********************
_pbc &= 0xcf;
_pb &= 0xcf;

//**led********************
_pec = 0x00;
_pe = 0x00;

//*****按鍵初始化*********
// _cp0c = 0x00;
//_cp1c = 0x00;
//_tmpc0= 0x00;
//_acerl= 0x00; //pa口其他的不能占用

}
void time0_init()
{
_tmpc0=0x00; // time 輸出腳不使能TP1A,TP1B_2,TP1B_1,TP1B_0,TP0_1,TP0_0
_tmpc1=0x00; // time 輸出腳不使能TP3_1,TP3_0,TP2_1,TP2_0
_tm0c0=0x00; //run,Fsys/4, off
_tm0c1=0xc1; //定時計數(shù)模式 CCRA
_tm0al=0xff;
_tm0ah=0x03; //最大為3
_mf0e=1; //多功能中斷0使能
_t0ae=1; //TM0 A匹配中斷控制位
_emi=1; //開總中斷
_t0on=1; //開定時器
}
#pragma vector isr_timer0 @ 0x14//定時器計數(shù)器0
void isr_timer0()
{
_t0af=0; //標(biāo)志必須清零
if(count>3000)
{
count=0;
_pe=~_pe;
}
else count++;
}
void DelayMs(unsigned long number) //延時
{
unsigned char temp;
for(;number!=0;number--)
{
for(temp=60;temp!=0;temp--);
_clrwdt();
}
}

void main()
{
initial();
time0_init();
while(1)
{
;
}
}



關(guān)鍵詞: HOLTEKht67f50單片機timer0定

評論


技術(shù)專區(qū)

關(guān)閉