<?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>topic I2C ROM drivers in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-ROM-drivers/m-p/570497#M18176</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 Nov 18 17:51:24 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I2C_PARAM_t&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;there is no documentation regarding the correct values to place in num_bytes_send and num_bytes_rec&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I need to send&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; address, command, data0, data1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and send/receive&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; address, command, (address w/read) receive data0, data1&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I do not know if the num_bytes_send should include the address byte or not, looks like it should via LPCOpen sample with i2c_master_transmit&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;but the same sample shows that a read does not include the address when doing a i2c_master_receive&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;a bit confusing given no documentation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 20:12:25 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T20:12:25Z</dc:date>
    <item>
      <title>I2C ROM drivers</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-ROM-drivers/m-p/570497#M18176</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 Nov 18 17:51:24 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I2C_PARAM_t&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;there is no documentation regarding the correct values to place in num_bytes_send and num_bytes_rec&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I need to send&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; address, command, data0, data1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and send/receive&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; address, command, (address w/read) receive data0, data1&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I do not know if the num_bytes_send should include the address byte or not, looks like it should via LPCOpen sample with i2c_master_transmit&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;but the same sample shows that a read does not include the address when doing a i2c_master_receive&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;a bit confusing given no documentation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:12:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-ROM-drivers/m-p/570497#M18176</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:12:25Z</dc:date>
    </item>
    <item>
      <title>Re: I2C ROM drivers</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-ROM-drivers/m-p/570498#M18177</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 Tue Nov 19 10:04:18 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;OK, I figured out that num_bytes_send and num_bytes_rec must include the address byte.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;But here is a strange one.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If I use the API i2c_master_transmit_intr() it works as expected.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;but if I use the API i2c_master_tx_rx_poll()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I get a strange attempt to read after sending, even though the receive buffer and bytes are 0.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This gives a false ERR_I2C_NAK&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;as seen in the capture&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;makes me think the polling function is borked.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV class="j-rte-table"&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca" style="border:1px solid black;background-color:#cacaca;"&gt; &lt;PRE&gt;
ErrorCode_t writeRegister(registers_t which, uint8_t *buffer)
{
uint8_t SendData[4];
I2C_PARAM_T param;

SendData[0] = address &amp;amp; 0xFE; // make sure bit 0 is 0
SendData[1] = (uint8_t)which;
SendData[2] = *buffer++;
SendData[3] = *buffer;

param.num_bytes_send&amp;nbsp;&amp;nbsp;&amp;nbsp; = 4;
param.buffer_ptr_send&amp;nbsp;&amp;nbsp; = SendData;
param.num_bytes_rec&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 0;
param.buffer_ptr_rec&amp;nbsp;&amp;nbsp;&amp;nbsp; = 0;
param.stop_flag&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 1;
param.func_pt&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = cbI2CComplete;
/* Set timeout (much) greater than the transfer length */
gErrorCode = -1;
LPC_I2CD_API-&amp;gt;i2c_set_timeout(i2cHandleMaster, 100000);
LPC_I2CD_API-&amp;gt;i2c_master_transmit_intr(i2cHandleMaster, &amp;amp;param, &amp;amp;result);
//gErrorCode = LPC_I2CD_API-&amp;gt;i2c_master_tx_rx_poll(i2cHandleMaster, &amp;amp;param, &amp;amp;result);
while (gErrorCode == -1)
{
__WFI();
}
if(gErrorCode != LPC_OK)
DEBUGOUT("i2c_master_receive error code : %x\r\b", gErrorCode);
return gErrorCode;
}

&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:12:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-ROM-drivers/m-p/570498#M18177</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:12:26Z</dc:date>
    </item>
  </channel>
</rss>

