lpcware

Detect I2C Stop on LPC812

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by remcopoelstra on Thu Nov 27 03:34:08 MST 2014
Hi,

I'm using an LPC812.
I'm trying to detect when a transfer has ended over the I2C bus. I've enabled the SLVDESEL interrupt, but my interrupt handler is only called when the address for the next transfer is received. The documentation states that SLVDESEL should also be set on a STOP condition.
I've set a breakpoint on the SLVDESEL handling code and I've included a screenshot of my scope, where can be seen that communication only stalls after the start of the next transfer.
Note that the address is the same, so if SLVDESEL only reacts on addresses, then it should not be set, as the same slave is addressed!

This is how I handle the SLVDESEL interrupt:

uint32_t pending=Chip_I2C_GetPendingInt(LPC_I2C0);

if (pending&I2C_INTSTAT_SLVDESEL) {
uint32_t monitor_read=LPC_I2C0->MONRXDAT;
Chip_I2CS_ClearStatus(LPC_I2C0,0xffffffff);
handle->callbacks->command_done(handle->buffer,!(monitor_read&I2C_MONRXDAT_MONNACK));
}
if (pending&I2C_INTSTAT_SLVPENDING) {
           /*Handle normal communication, works fine*/
        }


Since the SLVDESEL is too late, I read the wrong data from MONRXDAT, so I miss the acknowledge bit just before the STOP (which is what I'm interested in).

How can I reliably detect the STOP condition?

Thanks in advance.

Kind regards,

Remco Poelstra

Outcomes