怎么反复进中断
#pragma sfr#pragma NOP
#pragma DI
#pragma EI
#pragma interrupt INTTM000 fn_inttm000
sreg unsigned char g_ucTM000cnt = 0;
void Init_CPU (void)
{
WDTM = 0x70; /* CLOSE the wacthdog */
PCC = 0x00; /* set CPU clock to fx */
PPCC = 0x00;
LSRCM = 0x01; /* stop the low speed ring oscillator */
OSTS= 0x00; /* shortest stabilisation time 2^10/fx */
}
void Init_PORT(void)
{P2=0x00; /*set output latches ofp20 as low(turn off the LED)*/
PMC2=0x00; /*set P2 I/O mode*/
PM2=0xF0; /*set P20 as output */
P4=0x00;
PM4=0xC0;
}
void Init_TM00(void)
{TMMK000=0;
PRM00=0XA2; /*Count clock selection 32.25KHz*/
TMC00=0X00; /*close timer00*/
CRC00=0X00; /*CR000 compare*/
TOC00=0X00;
CR000=3225-1; /*CR000 as Comparator when TM00=CR000 will clear TM00*/
TMC00=0X0C; /*open timer00*/
IF0=0x00;
TMMK000=0;/*TM00 has no sign of interruption*/
}
void main(void)
{ DI();
Init_CPU ();
Init_PORT();
Init_TM00();
EI();
while(1){
NOP();
NOP();
}
}
__interrupt void fn_inttm000(){
if (++g_ucTM000cnt == 10){
g_ucTM000cnt = 0;
P4.5=1;
TMIF000=0;
}
return;
}
以上是我的程序,我想定时1S使灯反复点亮,可我的程序似乎第一次进中断后就出不来了!想知道怎么解决,还有我的一秒定时对吗?有没有更方便的方法?谢谢帮忙~ 呵呵,知道哪错了!因为中断里面的数始终不变,所以看不到灯的两灭,只要将P4.5=1;改为P4^=0B00100000;即可。。。
页:
[1]