I2C Slave not respecting NACK and STOP? | Cypress Semiconductor
I2C Slave not respecting NACK and STOP?
I have an I2C Component in my design, using Fixed Function block at 100kHz speed.
It is set in slave mode and initialized with a buffer of 250 Bytes.
The bytes in the buffer are all initialized with the values 0 to 249 to make debugging easier.
When my master (an external processor) READS from the slave it reads only 240 bytes from the buffer. The reads are all present and correct, and the master NACKs the last byte and performs a proper I2C Stop sequence.
In my Creator project I poll using I2C_SlaveStatus() and look for the I2C_SSTAT_RD_CMPLT flag.
In my handler when I see I2C_SSTAT_RD_CMPLT I reset the buffer using I2C_SlaveClearReadBuf();
The problem is that this flag doesn't get set after each read from the master, it only gets set after every 4 or 5 reads, and the slave continues reading through the buffer instead. (Returning 0xff once it overflows).
I have used a logic analyzer to look at the data and it decodes it as valid I2C with the correct timings and sequences.
Attached are 2 screen shots from my logic analyzer showing the end of the 1st 240 byte read and the start of the next read (which should have reset to the start of the buffer).
Any ideas as to why this should be behaving like this?
I cannot attach the whole project as large parts of it are under NDA to my client.
I will try to make a smaller project with just the I2C to show the problem.