hi all,
i'm posting a problem with my IOC routine.
i'm trying to use PORTB R5 with an IFR sensor that is normally at +5v and when a IFR barrier is sensed put RB5 to 0v causing an interrupt change on portb.
in the Interrupt Service Routine I recognize only changing on line 5 and when it happen a flag (IFR_ITR) is setted and tested in the main loop which is incrementing a counter that is resetted when this flag is setted.
the problem is that in normal condition (no IFR and no changed in signal applied to RB5) the flag IFR_ITR is set and the counter is resetted without any explanation after about 2 or 3 minutes.
i've displayed in main loop the values of RB5 (which is permanently to 1) and IFR_ITR(that in effect became 1)
any suggestion?please help me.
thankyou very much
following my ISR
i'm posting a problem with my IOC routine.
i'm trying to use PORTB R5 with an IFR sensor that is normally at +5v and when a IFR barrier is sensed put RB5 to 0v causing an interrupt change on portb.
in the Interrupt Service Routine I recognize only changing on line 5 and when it happen a flag (IFR_ITR) is setted and tested in the main loop which is incrementing a counter that is resetted when this flag is setted.
the problem is that in normal condition (no IFR and no changed in signal applied to RB5) the flag IFR_ITR is set and the counter is resetted without any explanation after about 2 or 3 minutes.
i've displayed in main loop the values of RB5 (which is permanently to 1) and IFR_ITR(that in effect became 1)
any suggestion?please help me.
thankyou very much
following my ISR
Code:
void interrupt isr(void)
{
GIE=0;
if(INTF)
{ // RB0 interrupt
cntr++ ; // inc. transition counter
INTF = 0 ; // clear interrupt flag to enable next call
}
else if(T0IF)
{ //TIMER 0 overflow
ovrflw++ ; // inc. overflow counter
T0IF = 0 ; // clear interrupt flag to enable next call on overflow
}
else if (TMR1IF){
cntoscurato++;
TMR1IF=0;
}
else if(RBIF)
{
if (RB5==0)
{
IFR_ITR=1 ;
}
RBIF = 0 ;
}
GIE=1;
}