<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>LPC MicrocontrollersのトピックRe: How to set I2C correctly?</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/How-to-set-I2C-correctly/m-p/567107#M17464</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by rocketdawg on Mon Dec 16 09:50:35 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;something like this.&amp;nbsp; Straight from LPCOpen source code. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
#ifdef __USE_LPCOPEN
&amp;nbsp;&amp;nbsp;&amp;nbsp; // Read clock settings and update SystemCoreClock variable
&amp;nbsp;&amp;nbsp;&amp;nbsp; SystemCoreClockUpdate();

&amp;nbsp;&amp;nbsp;&amp;nbsp; // Set up and initialize all required blocks and functions
&amp;nbsp;&amp;nbsp;&amp;nbsp; // related to the board hardware
&amp;nbsp;&amp;nbsp;&amp;nbsp; Board_Init();

&amp;nbsp;&amp;nbsp;&amp;nbsp; // Set the LED to the state of "Off"
&amp;nbsp;&amp;nbsp;&amp;nbsp; Board_LED_Set(0, false);

/* Setup I2C pin muxing */
Init_I2C_PinMux();

/* Allocate I2C handle, setup I2C rate, and initialize I2C
&amp;nbsp;&amp;nbsp; clocking */
setupI2CMaster();


/* Enable SysTick Timer */
SysTick_Config(SystemCoreClock / TICKRATE_HZ);

#endif
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
/* Initializes pin muxing for I2C interface - note that SystemInit() may
&amp;nbsp;&amp;nbsp; already setup your pin muxing at system startup */
static void Init_I2C_PinMux(void)
{
#if defined(BOARD_NXP_XPRESSO_812)
/* Enable the clock to the Switch Matrix */
Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SWM);

/* Connect the I2C_SDA and I2C_SCL signals to port pins(P0.10, P0.11) */
Chip_SWM_MovablePinAssign(SWM_I2C_SDA_IO, 10);
Chip_SWM_MovablePinAssign(SWM_I2C_SCL_IO, 11);

#if (I2C_BITRATE &amp;gt; 400000)
/* Enable Fast Mode Plus for I2C pins */
Chip_IOCON_PinSetI2CMode(LPC_IOCON, IOCON_PIO10, PIN_I2CMODE_FASTPLUS);
Chip_IOCON_PinSetI2CMode(LPC_IOCON, IOCON_PIO11, PIN_I2CMODE_FASTPLUS);
#endif

/* Disable the clock to the Switch Matrix to save power */
Chip_Clock_DisablePeriphClock(SYSCTL_CLOCK_SWM);

#else
/* Configure your own I2C pin muxing here if needed */
#warning No I2C pin muxing defined
#endif
}


/* Setup I2C handle and parameters */
void setupI2CMaster()
{
/* Enable I2C clock and reset I2C peripheral - the boot ROM does not
&amp;nbsp;&amp;nbsp; do this */
Chip_I2C_Init();

/* Perform a sanity check on the storage allocation */
if (LPC_I2CD_API-&amp;gt;i2c_get_mem_size() &amp;gt; sizeof(i2cMasterHandleMEM)) {
/* Example only: this should never happen and probably isn't needed for
&amp;nbsp;&amp;nbsp; most I2C code. */
errorI2C();
}

/* Setup the I2C handle */
i2cHandleMaster = LPC_I2CD_API-&amp;gt;i2c_setup(LPC_I2C_BASE, i2cMasterHandleMEM);
if (i2cHandleMaster == NULL) {
errorI2C();
}

/* Set I2C bit rate */
if (LPC_I2CD_API-&amp;gt;i2c_set_bitrate(i2cHandleMaster, Chip_Clock_GetSystemClockRate(), I2C_BITRATE) != LPC_OK) {
errorI2C();
}
/* Enable the interrupt for the I2C */
NVIC_EnableIRQ(I2C_IRQn);
}

&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 20:08:40 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T20:08:40Z</dc:date>
    <item>
      <title>How to set I2C correctly?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/How-to-set-I2C-correctly/m-p/567106#M17463</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by masterboy on Mon Dec 16 04:25:35 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can someone describe in detail the procedure to correctly calculate and set the registers for I2C? The chip (lpc812) run at 12 Mhz crystal and I need to set the I2C clock to 400 kHz. I do not understand what is written in UM.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:08:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/How-to-set-I2C-correctly/m-p/567106#M17463</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:08:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to set I2C correctly?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/How-to-set-I2C-correctly/m-p/567107#M17464</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by rocketdawg on Mon Dec 16 09:50:35 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;something like this.&amp;nbsp; Straight from LPCOpen source code. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
#ifdef __USE_LPCOPEN
&amp;nbsp;&amp;nbsp;&amp;nbsp; // Read clock settings and update SystemCoreClock variable
&amp;nbsp;&amp;nbsp;&amp;nbsp; SystemCoreClockUpdate();

&amp;nbsp;&amp;nbsp;&amp;nbsp; // Set up and initialize all required blocks and functions
&amp;nbsp;&amp;nbsp;&amp;nbsp; // related to the board hardware
&amp;nbsp;&amp;nbsp;&amp;nbsp; Board_Init();

&amp;nbsp;&amp;nbsp;&amp;nbsp; // Set the LED to the state of "Off"
&amp;nbsp;&amp;nbsp;&amp;nbsp; Board_LED_Set(0, false);

/* Setup I2C pin muxing */
Init_I2C_PinMux();

/* Allocate I2C handle, setup I2C rate, and initialize I2C
&amp;nbsp;&amp;nbsp; clocking */
setupI2CMaster();


/* Enable SysTick Timer */
SysTick_Config(SystemCoreClock / TICKRATE_HZ);

#endif
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
/* Initializes pin muxing for I2C interface - note that SystemInit() may
&amp;nbsp;&amp;nbsp; already setup your pin muxing at system startup */
static void Init_I2C_PinMux(void)
{
#if defined(BOARD_NXP_XPRESSO_812)
/* Enable the clock to the Switch Matrix */
Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SWM);

/* Connect the I2C_SDA and I2C_SCL signals to port pins(P0.10, P0.11) */
Chip_SWM_MovablePinAssign(SWM_I2C_SDA_IO, 10);
Chip_SWM_MovablePinAssign(SWM_I2C_SCL_IO, 11);

#if (I2C_BITRATE &amp;gt; 400000)
/* Enable Fast Mode Plus for I2C pins */
Chip_IOCON_PinSetI2CMode(LPC_IOCON, IOCON_PIO10, PIN_I2CMODE_FASTPLUS);
Chip_IOCON_PinSetI2CMode(LPC_IOCON, IOCON_PIO11, PIN_I2CMODE_FASTPLUS);
#endif

/* Disable the clock to the Switch Matrix to save power */
Chip_Clock_DisablePeriphClock(SYSCTL_CLOCK_SWM);

#else
/* Configure your own I2C pin muxing here if needed */
#warning No I2C pin muxing defined
#endif
}


/* Setup I2C handle and parameters */
void setupI2CMaster()
{
/* Enable I2C clock and reset I2C peripheral - the boot ROM does not
&amp;nbsp;&amp;nbsp; do this */
Chip_I2C_Init();

/* Perform a sanity check on the storage allocation */
if (LPC_I2CD_API-&amp;gt;i2c_get_mem_size() &amp;gt; sizeof(i2cMasterHandleMEM)) {
/* Example only: this should never happen and probably isn't needed for
&amp;nbsp;&amp;nbsp; most I2C code. */
errorI2C();
}

/* Setup the I2C handle */
i2cHandleMaster = LPC_I2CD_API-&amp;gt;i2c_setup(LPC_I2C_BASE, i2cMasterHandleMEM);
if (i2cHandleMaster == NULL) {
errorI2C();
}

/* Set I2C bit rate */
if (LPC_I2CD_API-&amp;gt;i2c_set_bitrate(i2cHandleMaster, Chip_Clock_GetSystemClockRate(), I2C_BITRATE) != LPC_OK) {
errorI2C();
}
/* Enable the interrupt for the I2C */
NVIC_EnableIRQ(I2C_IRQn);
}

&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:08:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/How-to-set-I2C-correctly/m-p/567107#M17464</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:08:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to set I2C correctly?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/How-to-set-I2C-correctly/m-p/567108#M17465</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by vijay_nav on Tue Dec 31 23:31:45 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hai&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I am Working on i2c project while building&amp;amp;Debugging i am facing the&amp;nbsp; error that undefined reference to `I2CMonBuffer',I2CSlaveRXBuffer,I2CSlaveTXBuffer. please find the below attachments for the program and screen shot for bugs.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Please help how to fix it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:08:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/How-to-set-I2C-correctly/m-p/567108#M17465</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:08:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to set I2C correctly?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/How-to-set-I2C-correctly/m-p/567109#M17466</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by vijay_nav on Wed Jan 29 05:04:35 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hai &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am working on I2c and i my device is acting act as slave and my address is matched with other device.But i have a dought&amp;nbsp; how to send acknowledgement to the other device.This is the code for slave.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:08:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/How-to-set-I2C-correctly/m-p/567109#M17466</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:08:41Z</dc:date>
    </item>
  </channel>
</rss>

