I'm getting some weird behaviour with my slave IIC driver on FRDM-KL02Z board (REV C, REV B) when STOP interrupt is enabled. This is my slave driver:
void IicSlaveInit( void){
IIC->C1 = 0;
IIC->FLT |= I2C_FLT_STOPIE_MASK; // enable stop interrupt
IIC->C1 |= I2C_C1_IICEN_MASK; // enable
IIC->C1 |= I2C_C1_IICIE_MASK; // enable interrupt
}
static int Event; // just some dummy variable...
void __irq I2C0_IRQHandler( void) {
if(IIC->S & I2C_S_IAAS_MASK) { // BKPT1
Event = 0;
} else if(IIC->FLT & I2C_FLT_STOPF_MASK) {
Event = 1;
} else if(IIC->S & I2C_S_TCF_MASK) {
Event = 2; // BKPT2
} else {
Event = 3;
}
IIC->C1 &= ~I2C_C1_IICIE_MASK;
}
With STOP interrupt enabled in IicSlaveInit() function the ISR is executed (and ends with Event == 2) on IIC START condition. I expect no interrupt on START condition.
Notes:
1) Before the test, IIC bus is idle (both SDA and SCL pulled high by pull up resistors). Nothing else than the IIC START condition happens on the bus (observed by scope).
2) With STOP interrupt disabled there is no interrupt when START condition appers on the bus.
Why this happens?