Hi.
I have seen here a lot of question about unexpected behavior of TC8418 when multiple keys pressed.
I want to share my solution to the problem.
I faced this problem a few years ago.
When pressed several keys together or press keys very quickly, controller TCA8418 begin send incorrect data(pressed one key, but controller send code of another key), and continue send incorrect code until reset of controller.
I think the problem is in TCA8418's state machine when it works with FIFO. Send simultaneously via I2C long message(FIFO--) and save to FIFO new pressed keys(FIFO+).
The solution, that I found, is read only one event from TCA8418 for one time regardless of quantity of events in TCA8418’s FIFO:
//Read KBC Key Event Counter
i2cWrBuffer[0] = 3;
i2cTransaction.writeCount = 1;
i2cTransaction.readCount = 1;
I2C_transfer(i2cHandle, &i2cTransaction); // read number of key events
j = i2cRdBuffer[0] & 0x0F; //number of key events
//Read always only ONE key event, otherwise a KBC may send wrong data
i2cWrBuffer[0] = 4;
i2cTransaction.writeCount = 1;
i2cTransaction.readCount = 1;//j;
I2C_transfer(i2cHandle, &i2cTransaction); //Read key events
Since, past three years, and this problem not appear anymore.
Best Regards.