I2C interrupt issue in LPC1788

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

I2C interrupt issue in LPC1788

1,727 Views
parthchoksi
Contributor II

I've got an LPC1788 that refuses to generate an interrupt or set the Serial Interrupt (SI) flag in I2C1->CONSET after successfully generating a start condition for a Master Transfer.

 

My current setup has an LPC1788 with nothing on the I2C bus except the external pullups (Note: I can drive the lines manually if I set them to GPIO mode and write the registers, so there's nothing wrong hardware wise). My code compiles and runs, and works with other peripherals, but I've stripped out all of the code to just the I2C Code. No slaves have been initialized.

I am also attaching my code. 

can anyone get me out of this problem?

int main()

{

/*********** Pin discreption ***************/

PINSEL_ConfigPin (0, 0, 3); // SDA Pin for Port 0   
PINSEL_ConfigPin (0, 1, 3); // SCL Pin for Port 1
PINSEL_SetOpenDrainMode(0, 0, ENABLE);
PINSEL_SetOpenDrainMode(0, 1, ENABLE);

// Initialize I2C 
I2C_Init( I2C1 , 100000);         // Initialize I2C1 at 100Khz clock rate

/* Enable I2C operation */

I2C-> CONSET  = 0x40; 

// Disable interrupt to ensure code stay stuck in while loop. No change with either On or Off

//NVIC_EnableIRQ(I2C1_IRQn);
//NVIC_SetPriority(I2C1_IRQn,((0x02<<3)|0x01));

// Reset STA, STO, SI
I2Cx->CONCLR = I2C_I2CONCLR_SIC;
I2Cx->CONCLR = I2C_I2CONCLR_STOC;
I2Cx->CONCLR = I2C_I2CONCLR_STAC;

// Enter to Master Transmitter mode 
I2Cx->CONSET = I2C_I2CONSET_STA;   // Generate start bit

whille(1);

}

4 Replies

1,023 Views
danielholala
Senior Contributor II

Parth,

According to the user manual of LPC1788 (Table 74), you are using pins that are not specialized for use with I2C (as can be seen from the fact that you have to configure the open drain mode explicitly).

I suggest you connect your I2C bus to specialized pins, e.g., P0[27]/ I2C0_SDA/ USB_SDA and P0[28]/ I2C0_SCL/ USB_SCL and try again. According to the manual, these pins provide an analog filter to suppress line glitches.

Best regards,

Daniel

0 Kudos

1,023 Views
victorjimenez
NXP TechSupport
NXP TechSupport

Hello Parth,

I highly recommend you to see the I2C example of the LPCOpen for  the LPC1788. In that example the interrupts of the I2C are configured and the example works fine, so you can use this as a guide to compare with your project and see which configurations you are missing. 

Hope it helps! 

Have a great day, 

Victor.

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,023 Views
parthchoksi
Contributor II

Hello Victor Jimenez,

I have tried that I2C example of LPC 1788 but got same issue as serial interrupt is generated but not every time. It has to be something missing in I2C configuration in that example of LPC 1788 so that interrupt is not generate and i tried too much to find it but not got the answer. So if you get any solution regarding this problem reply me as much as possible and thanks for reply.

Have a Nice day,

Parth

0 Kudos

1,023 Views
victorjimenez
NXP TechSupport
NXP TechSupport

Hello Parth, 

Could you be more specific and detail in which occasions the interruption is not generated (when you want to read to slave, to write from the slave, etc.) ?

Have a great day, 

Victor.

0 Kudos