Hello
I using "MCC" to configure IOC of "RB4" as "any". The CPU is interrupted as i expected but i can't clear interrupt condition so CPU will looped in ISR. I read the datasheet, in datasheet mentioned that :
And clear the "" flag on main ISR function as followin :
Note : I checked assembly code resulted from my code and ensure that the "PORTB" is not read with "MOVFF" instruction.
Are there any mistakes in my codes ?
I using "MCC" to configure IOC of "RB4" as "any". The CPU is interrupted as i expected but i can't clear interrupt condition so CPU will looped in ISR. I read the datasheet, in datasheet mentioned that :
So i write my ISR as :The user, in the Interrupt Service Routine, can clear the interrupt in the following manner:
1. Any read or write of PORTB to clear the mis-match condition (except when PORTB is the source or destination of a MOVFF instruction).
2. Execute at least one instruction after reading or writing PORTB, then clear the flag bit, RBIF.
Code:
void myISR(void)
{
//Only for clear interrupt condition.
if (PORTB == 0) NOP();
flag = true;
}
Code:
void PIN_MANAGER_IOC(void)
{
// interrupt on change for pin IOCB4
if(IOCBbits.IOCB4 == 1)
{
myISR();
}
// Clear global Interrupt-On-Change flag
INTCONbits.RBIF = 0;
}
Are there any mistakes in my codes ?