lpcware

Clock settings for LPC11U14 target board in I2C Fast mode

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Sathiyakala on Tue Sep 11 04:32:38 MST 2012
:confused:Is the below program will set the clock correctly for a master transmitter operation for a 400Khz I2C interface?

void I2CInit()
{
  LPC_SYSCON->PRESETCTRL |= (1<<2);

  LPC_SYSCON -> SYSAHBCLKDIV |=(1<<1);

  LPC_SYSCON->SYSAHBCLKCTRL |= (1<<5);


  LPC_IOCON->PIO0_4 |= 0x81;/* I2C SCL */

  LPC_IOCON->PIO0_5 |= 0x81;/* I2C SDA */

 
  LPC_I2C->SCLL   = 0x0000000F;
  LPC_I2C->SCLH   = 0x0000000F; //For 12MHZ frequency

  /*--- Clear flags ---*/
  LPC_I2C->CONCLR = I2CONCLR_AAC | I2CONCLR_SIC | I2CONCLR_STAC | I2CONCLR_I2ENC;

  LPC_I2C->CONSET = I2CONSET_I2EN|I2CONSET_STA;

}

Outcomes