本帖最后由 hiramlee 于 2013-8-21 18:19 编辑
我同时使用了一个UART中断 一个外部中断 两个定时器中断TIMR0 TIMR1,
当不使用TIMR1程序工作完好,
当加上TIMR1后TIMR0的中断ISR没有被执行。求指点
static void interrupt rx_handler ()
{
if(TMR1IF&&TMR1IE )
{
// GIE =0;
TMR1H = DeltaT[nMode+1]>>8 ;
TMR1L = DeltaT[nMode+1]&0x00ff ;
//asm("MOVLW TL_TIMER0");
//asm("MOVWF TMROL,0");
TMR1IF = 0;
switch(nMode)
{
case Mode1:
case Mode2:
case Mode3:
case Mode5:
{
PORTCbits.RC2=0;
PORTCbits.RC2=1;
_delay(9);
PORTCbits.RC2=0;
break;
}
case Mode4:
{
PORTCbits.RC2=0;
PORTCbits.RC2=1;
_delay(119);
PORTCbits.RC2=0;
break;
}
default:
{
}
}
// GIE =1;
}
if(PIE1bits.RCIE & PIR1bits.RCIF) //判断是否为串口接收中断
{
// INTCONbits.GIE = 0;
// PIR1bits.RCIF =0;
//Delay1KTCYx(1);
while(BusyUSART());
RCREG_NEW = getcUSART();
//putcUSART(RCREG_R);
while(BusyUSART());
//INTCONbits.GIE = 1;
// Pulse = !Pulse;
}
if(INT0IF)
{
INT0IF=0;
KeyDetect();
}
if(TMR0IF&&TMR0IE )
{
GIE =0;
TMR0H = DeltaT[nMode]>>8 ;
TMR0L = DeltaT[nMode]&0x00ff ;
//asm("MOVLW TL_TIMER0");
//asm("MOVWF TMROL,0");
TMR0IF = 0;
switch(nMode)
{
case Mode1:
case Mode2:
case Mode3:
case Mode5:
{
PORTCbits.RC1=0;
PORTCbits.RC1=1;
_delay(9);
PORTCbits.RC1=0;
break;
}
case Mode4:
{
PORTCbits.RC1=0;
PORTCbits.RC1=1;
_delay(119);
PORTCbits.RC1=0;
break;
}
default:
{
}
}
GIE =1;
}
}
|