AnsweredAssumed Answered

LPC1769 for I2C communication

Question asked by Hitotsu Asahi on Aug 3, 2016
Latest reply on Sep 5, 2016 by Kerry Zhou



I started learning to use the I2C function of LPC1769.

Could anyone provide me the sample program for the initialization and data transmission of I2C related registers?


I tried to create my code based on the information from the user's manual of 1769, but it is too complicated for me to understand exactly what kind of setting is correct. I also tried the sample code of LPCOPEN (sample code for using EEPROM) but it is also complicated too, and I even could not compile it.


What I would like to do is just

(1) initialize the I2C setting, and

(2) send binary signal from SDA pin (P0_28) like LOW, HIGH, LOW, HIGH... in parallel with the clock from SCL pin (P0_27).


I know the protocol of I2C and what kind of signal should be sent from the pins. I am not sure just how to adjust the register setting of LPC1769.


What I understood from the manual is that following setting may be required, but it might be incorrect;



LPC_SC->PCONP |= (1 << 7);           //Power on PCI2C0

LPC_SC->PCLKSEL0 |= (3 << 14);     //Input clock to I2C0 (φ/8)

LPC_PINCON->PINSEL1 |= (1<<22);   //P0_27  to SCL mode

LPC_PINCON->PINSEL1 &= ~(1<<23);      //P0_27 to SCL mode

LPC_PINCON->PINSEL1 |= (1<<24);          //P0_28 to SCL mode

LPC_PINCON->PINSEL1 &= ~(1<<25);     //P0_28をSCL mode

LPC_I2C0->I2CONSET = 0x40;                //enable I2C

LPC_I2C0->I2SCLH = 0x06;                    

LPC_I2C0->I2SCLL = 0x06;                    

...anything else?


<Data transmission>

I have no idea.


The support would be highly appreciated.