<?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: I2C xfer question using the LPCOpen framework [SOLVED]</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-xfer-question-using-the-LPCOpen-framework-SOLVED/m-p/526331#M8961</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by 1234567890 on Sat Dec 06 04:54:06 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Indeed you only have to write the fields with changed values. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;But this is a allways-safe function. And usually you change [u]all[/u] values during runtime of a program (address, sizes, sometimes buffers as well) and this avoids using an outdated wrong value.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 17:04:09 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T17:04:09Z</dc:date>
    <item>
      <title>I2C xfer question using the LPCOpen framework [SOLVED]</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-xfer-question-using-the-LPCOpen-framework-SOLVED/m-p/526330#M8960</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by fjrg76 on Fri Dec 05 17:57:04 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm using the I2C peripheral for the first time with this CPU and the LPCOpen framework. I'm aware on how I2C works and I've been using it with other chips (LPC1114, LPC2103, etc.) While studying the code in the example "&lt;/SPAN&gt;&lt;I&gt;periph_i2cm_polling.c&lt;/I&gt;&lt;SPAN&gt;" I noted that the struct variable &lt;/SPAN&gt;&lt;STRONG&gt;i2cmXferRec&lt;/STRONG&gt;&lt;SPAN&gt; is filled everytime that the function&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Chip_I2CM_XferBlocking(LPC_I2C0, &amp;amp;i2cmXferRec)&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;is called. Is that really needed? I mean, it can be filled just once, and then just check the field &lt;/SPAN&gt;&lt;STRONG&gt;.status&lt;/STRONG&gt;&lt;SPAN&gt; after each calling. Is that behavior because of the example, or it is the way the function &lt;/SPAN&gt;&lt;STRONG&gt;Chip_I2CM_XferBlocking()&lt;/STRONG&gt;&lt;SPAN&gt; is used? I'm pasting a cropped code so you get a better idea about I'm talking about. From the code below it's seen that it's not needed to refill the struct every time because almost all fields remain unchanged, except the &lt;/SPAN&gt;&lt;STRONG&gt;.status&lt;/STRONG&gt;&lt;SPAN&gt; field (and the buffers pointed by the pointers, but the pointers themself doesn't change either).&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;static void SetupXferRecAndExecute(uint8_t devAddr, uint8_t *txBuffPtr, uint16_t txSize, uint8_t *rxBuffPtr, uint16_t rxSize)
{
i2cmXferRec.slaveAddr = devAddr;
i2cmXferRec.status = 0;
i2cmXferRec.txSz = txSize;
i2cmXferRec.rxSz = rxSize;
i2cmXferRec.txBuff = txBuffPtr;
i2cmXferRec.rxBuff = rxBuffPtr;

Chip_I2CM_XferBlocking(LPC_I2C0, &amp;amp;i2cmXferRec);
}

static void ReadTemperatureI2CM(void)
{
uint8_t temperature[2];
uint8_t lm75TempRegisterAddress = 0;

SetupXferRecAndExecute( I2C_TEMP_ADDR_7BIT, &amp;amp;lm75TempRegisterAddress, 1, temperature, 2);

if (i2cmXferRec.status == I2CM_STATUS_OK) {
/* Do something */
}
else {
/* Do something*/
}
}

int main(void)
{
/* Setup I2C ... */


/* More setup ... */

while (1) {
while (lastState == state) { __WFI(); }

ReadTemperatureI2CM();
}

return 0;
}&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you!!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:04:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-xfer-question-using-the-LPCOpen-framework-SOLVED/m-p/526330#M8960</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: I2C xfer question using the LPCOpen framework [SOLVED]</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-xfer-question-using-the-LPCOpen-framework-SOLVED/m-p/526331#M8961</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by 1234567890 on Sat Dec 06 04:54:06 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Indeed you only have to write the fields with changed values. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;But this is a allways-safe function. And usually you change [u]all[/u] values during runtime of a program (address, sizes, sometimes buffers as well) and this avoids using an outdated wrong value.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:04:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-xfer-question-using-the-LPCOpen-framework-SOLVED/m-p/526331#M8961</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: I2C xfer question using the LPCOpen framework [SOLVED]</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-xfer-question-using-the-LPCOpen-framework-SOLVED/m-p/526332#M8962</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by fjrg76 on Tue Dec 23 19:32:18 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: 1234567890&lt;/STRONG&gt;&lt;BR /&gt;Indeed you only have to write the fields with changed values. &lt;BR /&gt;But this is a allways-safe function. And usually you change [u]all[/u] values during runtime of a program (address, sizes, sometimes buffers as well) and this avoids using an outdated wrong value.&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That's right!! I found that when using only and only one I2C device it's enough to fill the struct once. However, a typical system has more than one I2C device on-board; so one needs to update the struct fields whenever communicating with any other device.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:04:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-xfer-question-using-the-LPCOpen-framework-SOLVED/m-p/526332#M8962</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:04:09Z</dc:date>
    </item>
  </channel>
</rss>

