I've been trying to interface a capacitive touch controller IC from ATMEL (AT42QT1070) with #Kinetis mke04z128 MCU through #I2C bus. The routine for reading data from the device is as follows.
1. START I2C
2. Send device slave address with write bit.
3. Send address of memory location which we wish to read.
4. STOP I2C
5. START I2C
6. Send device slave address with read bit.
7. The device will then send an ACK followed by the data byte.
8. Master sends NACK to end data transfer.
9. STOP I2C
I'm running this routine continuously in a loop to read from the device. But sometimes in the loop, when I change the master to receive mode, instead of receiving data from the slave, the data buffer shows the last data sent to the slave which is the slave address with read bit. As i stepped in to the code while trying to debug, I found out that the SDA line was held low by the slave while the master wants it to be high during the address transmission. So the master goes to Loss of Arbitration fault and communication halts. This is not happening every-time I run this routine, It's random, but once it happens the bus goes idle and thus communication halts.
The bus lines are pulled up using 4.7 K resistors (Tried 10K too). I tried different baud rates from 100KHz to 400KHz (which is the maximum as per IC datasheet)
What could be the issue with the slave to hold the SDA low? How do we solve this issue?