void interrupt CP4int()//捕获中断
{
Set_BZ();
*PCDATDIR=*PCDATDIR ^ 0x0010;//test
kick_dog();
HH=*CAP1FIFO;
*EVAIFRC=*EVAIFRC & 0xffff; //清中断标志
asm (" clrc INTM"); //中断允许
}
int Mcu_Initial()
{
*SCSR1=0x83ff;
*WDCR=0x02f; //看门狗
*WDKEY =0x55;
*WDKEY =0xaa;
*MCRA = 0x000b; //PA3=CAP1 ,232
*MCRB =0xfe00;
*MCRC =0x0000;
*PFDATDIR=0XFF00; //输出
*PEDATDIR=0xFF00;
*PDDATDIR=0xFF00;
*PCDATDIR=0xFF00;
*PBDATDIR=0xFF00;
*PADATDIR=0xFF00;
*PADATDIR=*PADATDIR & 0xFB00; ////输入 PA2
*PBDATDIR=*PBDATDIR & 0xCF00; //PB4
*PFDATDIR=*PFDATDIR & 0xFD00; //PF1
*T2CON=0x104c
*T2PR=0xfffe;
*T2CNT=0;
*CAPCONA=0xa0C0;////cap1捕获,使能
*EVAIMRC=0x0001;//中断使能
*EVAIFRC=*EVAIFRC & 0xffff; //清中断标志
*IMR=0x0008;//cp4
*IFR=0x0ffff;
}
/////////
void interrupt nothing()//保护
{
kick_dog();
asm (" clrc INTM"); //开总中断
}
/////////
void main(void)
{
int i,j;
Mcu_Initial();
asm (" clrc INTM"); //开总中断
Clr_BZ();
while(1)
{ kick_dog();
sent_1ms_delay();
Clr_BZ();
sent_1ms_delay();
}
}
///////