LPC1788 I2C stuck in 0xF8 stage (SI=0)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC1788 I2C stuck in 0xF8 stage (SI=0)

1,702 Views
rameshlalji9595
Contributor II

I'm using a LPC1788, I have interfaced I2C in Master Transmitter mode. When i run my code after couple of seconds or minutes its gets stuck into 0xF8 stage and SI flag gets cleared and next interrupt refused to generate. So I2C gets stopped. So i have to re-init the I2C after SI gets clear(its working).

So what would be the reason behind this problem ?

Is there anything missing in my code(like delay or something else) or I2C configuration ?

So please can anyone get me out of this problem?

Note: When I using my code in debug by set break point at every stage (0x08, 0x18, 0x28) its working fine. Its stuck into F8 when i full run my code.

Note: I wish to restart I2C at every time when data byte transmitted successfully. There is no stop condition for I2C in my code.

I2C Configuration:

{

PINSEL_ConfigPin (0, 10, 2); // SDA Pin for Port 0.10
PINSEL_ConfigPin (0, 11, 2); // SCL Pin for Port 0.11
PINSEL_SetOpenDrainMode(0, 10, ENABLE); // Enable Open Drain Mode for SDA
PINSEL_SetOpenDrainMode(0, 11, ENABLE); // Enable Open Drain Mode for SCL
PINSEL_SetPinMode(0, 10, PINSEL_BASICMODE_PULLUP); // Select Plain output for SDA
PINSEL_SetPinMode(0, 11, PINSEL_BASICMODE_PULLUP); // Select Plain output for SCL


LPC_SC->PCONP |= (1 << 26); // Turn on power bit for I2C2 in PCONP register

/*--- Clear flags ---*/
LPC_I2C2->CONCLR = I2CONCLR_AAC | I2CONCLR_SIC | I2CONCLR_STAC | I2CONCLR_I2ENC;
/* Set clock rate */
I2C_SetClock(LPC_I2C2,100000);

LPC_I2C2->CONSET = I2CONSET_I2EN; // Enable I2C2 Mode1
}

I2C Master Transmitter Mode:

I2CStatus = I2Cx->STAT;

switch(I2CStatus)

{

   case 0x08:                 /* A Start condition is issued. */

   case 0x10:                  /* A repeated started is issued */

   I2Cx->DAT = Address & 0xFF;
   I2Cx->CONCLR = (I2CONCLR_SIC | I2CONCLR_STAC);
   I2CMasterState = I2C_STARTED;
   break;

   case 0x18:                     /* Regardless, it's a ACK */
   I2Cx->DAT = Data;
   I2Cx->CONSET = I2CONSET_AA; /* Set assert ACK flag */
   I2Cx->CONCLR = I2CONCLR_SIC;
   I2CMasterState = DATA_ACK; // changed
   break;

   case 0x28:           /* Data byte has been transmitted, regardless ACK or NACK */
   case 0x30: 
   
   I2Cx->CONSET = I2CONSET_STA; /* Set Repeated-start flag */
   I2Cx->CONCLR = I2CONCLR_SIC;
   I2CMasterState = I2C_RESTARTED;
   break;

   default: /* Default */
   I2Cx->CONCLR = I2CONCLR_SIC;
   I2C_IN_MasterState = I2C_STOP;
   break;

   /* Other cases also added 0x20, 0x38, */

}

Labels (1)
0 Kudos
Reply
1 Reply

1,343 Views
soledad
NXP Employee
NXP Employee

Hi, 

Please check the below threads and let me know if this helps. 

I2C interrupt issue in LPC1788 

[CMSIS][LPC1768] I2C bus locked up 

https://community.nxp.com/thread/422440 

Have a nice day. 

Regards 

Sol 

0 Kudos
Reply