请帮忙看一下,下面的程序为啥板子通电后没按任何按键的情况下,蜂鸣器器就会叫。
#include "REG_MA84G564.H"
#define T0_1MSL 0x18 // ( 65536 - 1000 )%256 in 12Mhz
#define T0_1MSH 0xFC // ( 65536 - 1000 )/256 in 12Mhz
unsigned char T0Cnt;
void INT_TIMER0(void) interrupt 1 using 1 // Timer0 Interrupt
{
WDTCR = 0x17; // Reset Watch Dog Timer
TR0 = 0; // Disable Timer0
if ( T0Cnt )
{
T0Cnt--;
TL0 = T0_1MSL;
TH0 = T0_1MSH;
TR0 = 1; // Enable Timer0
}
}
void delayms( unsigned char X )
{
TR0 = 0; // Disable Timer0
T0Cnt = X; // X*1ms = Xms
TL0 = T0_1MSL;
TH0 = T0_1MSH;
TR0 = 1; // Enable Timer0
while( T0Cnt );
}
void bell(void)
{
P24=0;
delayms(200);
P24=1;
delayms(100);
P24=0;
delayms(50);
P24=1;
delayms(100);
}
void INT_KB(void) interrupt 13
{
bell();
}
void main(void)
{
TMOD = 0x11; // Set Timer0/1 in Mode1/2 ( 16/8 bit )
TR0 = 0; // Desable Timer0
ET0 = 1;
EIE1 |= 0x20;
EIP1H |= 0x20;
EIP1L |= 0x20;
KBPATN = 0xff;
KBCON = 0x03;
KBMASK = 0xff; // Will Disable KP Interrupt
AUXR1 &= 0x3f;
EA=1;
while(1);
} |