AnsweredAssumed Answered

I2C stop condition problem

Question asked by Brian Smith on Apr 29, 2019
Latest reply on Apr 30, 2019 by Kerry Zhou



Recently i've been trying to implement non-blocking I2C transfers on my FRDM-k22f but i'm struggling to make proper transfers.


As example i'm trying to send slave adress, register address and 2 data bytes but at the end i end up with 5 bytes instead of 4. I double check and i write to data register only 4 times so it seems analyzer sees random states on the bus as a byte?


I checked how much interrupts i get and there is 1 caused by STARTF, 4 caused by TCF and one by STOPF which seems to correct using this way of thinking:


1. startf - slaveaddress
2. regaddress
3. data
4. data
5. no data to send - generate stop condition
6. stopf interrupt


Now the problem starts because even i got interrupt by stopf i cannot get correct stop condition on the bus?


At 5th interrupt i use my I2C_stop function to generate stop condition:


void I2C_stop(I2C_Type *base)
         base->C1 &= ~(I2C_C1_MST_MASK|I2C_C1_TX_MASK|I2C_C1_TXAK_MASK);


That's how it looks on analyzer:


Any ideas what might be wrong? I followed block schematic from k22f manual to properly handle interrupts but it's still not enough to get it going.