lpcware

LPC812 I²C interrupt: MSTPENDING=1 and MSTSTATE=0 - what does this mean?

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Helmut Stettmaier on Sat Mar 22 04:47:12 MST 2014
Hello,
I kindly ask for some information regarding LPC812's I²C interrupt status.
I use I²C in master mode, there is only one slave (an MS5611), communication is interrupt driven.
Timing is controlled by an MRT channel.
All this works... nearly perfectly, initialisation of the slave is ok, the values read from the slave look fine.

After some time (10..20 s) the system hangs up in the I²C interrupt handler. The handler looks as follows (I only purged some debugging code):

void I2C_IRQHandler(void) {
uint32_t cpySTAT= LPC_I2C->STAT & 0x0f;
LPC_I2C->STAT= MSTPENDING; // clear the Pending-Bit
switch (cpySTAT) {
case 1: return;
case 3:
// some code to save the data byte ...
currI2Cdata= currI2Cdata<<8 | LPC_I2C->MSTDAT;
// yes, max. 4 bytes
if (i2cCnt) { // ...and to continue
i2cCnt--;
LPC_I2C->MSTCTL= MSTCONTINUE;
return;
}
// ...or to stop this communication
// at the end of the handler
break;
case 5:
if (i2cCnt) { // some code to feed the transmitter ...
LPC_I2C->MSTDAT= currI2Cdata & 0xff;
currI2Cdata>>=8;
// yes, << when reading and >> when sending,
// but it doesn't hurt here
i2cCnt--;
LPC_I2C->MSTCTL= MSTCONTINUE;
return;
}
   // ...or to stop this communication at the end of the handler
break;
case 7:
case 9:
// if the address or data are NAKed (only one
// slave who guarantees accepting data)
// there is reason for some panic.
MS5611nextstate= MS5611panic;
}
// some code to stop the communication
LPC_I2C->MSTCTL= MSTSTOP;
LPC_I2C->INTENCLR= 1;
MS5611state= MS5611nextstate;
MS5611nextstate= MS5611undef;
return;
}


The problem is: I don't know, what case 1 means. The I²C peripheral device is busy, but the reason, why the interrupt is fired, is described not very clearly:
"MSTSTATE ... 0x0 Idle. The Master function is available to be used for a new transaction."
Which are the circumstances which let it occur? What is to be done?
Please note: The device has run for several seconds and this communication with the slave has already been executed for 100 or more times when the interrupt is fired with
MSTPENDING=1 and MSTSTATE=0.
In short words: What is to be programmed under case 1? I have no idea:-)
Sample codes usually use polling or are very simple and do not help answering this question.

Thank you for your effort and kind regards,
Helmut

Outcomes