<?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 Repeated start</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-Repeated-start/m-p/513255#M87</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by bobi-one on Wed Oct 29 07:52:20 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Writing to the WHO_I_M register of the slave doesn't return the expected value( only a couple of times actually did), so i presume the communication with it is not&amp;nbsp; working correctly. I did not observe any error conditions from the I2C .&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 17:05:21 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T17:05:21Z</dc:date>
    <item>
      <title>I2C Repeated start</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-Repeated-start/m-p/513251#M83</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by bobi-one on Mon Oct 27 06:41:33 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I Am trying to interface an&amp;nbsp; accelerometer with LPC1549 and trying to use the LPCOpen library.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Reusing the example for periph_i2cm_interrupt. I noticed that my chip requires repeated start when reading from it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;How can i modify&amp;nbsp; SetupXferRecAndExecutein order to do such thing?&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,
&amp;nbsp;&amp;nbsp; uint8_t *txBuffPtr,
&amp;nbsp;&amp;nbsp; uint16_t txSize,
&amp;nbsp;&amp;nbsp; uint8_t *rxBuffPtr,
&amp;nbsp;&amp;nbsp; uint16_t rxSize)
{
/* Setup I2C transfer record */
i2cmXferRec.slaveAddr = devAddr;
i2cmXferRec.status = 0;
i2cmXferRec.txSz = txSize;
i2cmXferRec.rxSz = rxSize;
i2cmXferRec.txBuff = txBuffPtr;
i2cmXferRec.rxBuff = rxBuffPtr;

Chip_I2CM_Xfer(LPC_I2C0, &amp;amp;i2cmXferRec);
/* Enable Master Interrupts */
Chip_I2C_EnableInt(LPC_I2C0, I2C_INTENSET_MSTPENDING | I2C_INTENSET_MSTRARBLOSS | I2C_INTENSET_MSTSTSTPERR);
/* Wait for transfer completion */
WaitForI2cXferComplete(&amp;amp;i2cmXferRec);
/* Clear all Interrupts */
Chip_I2C_ClearInt(LPC_I2C0, I2C_INTENSET_MSTPENDING | I2C_INTENSET_MSTRARBLOSS | I2C_INTENSET_MSTSTSTPERR);
}
&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 17:05:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-Repeated-start/m-p/513251#M83</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:05:18Z</dc:date>
    </item>
    <item>
      <title>Re: I2C Repeated start</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-Repeated-start/m-p/513252#M84</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by NXP_Paul on Mon Oct 27 08:43:29 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Generally, you only need to specify a value greater than zero for rxSize (i2cmXferRec.rxSz = rxSize).&amp;nbsp; This should provide the repeated start between the tx and rx messages.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Paul&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:05:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-Repeated-start/m-p/513252#M84</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:05:19Z</dc:date>
    </item>
    <item>
      <title>Re: I2C Repeated start</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-Repeated-start/m-p/513253#M85</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by bobi-one on Wed Oct 29 05:52:23 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the reply Paul,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Those are the functions that i wrote. But it seems the data that is coming&amp;nbsp; isn't quite as expected ( I cannot put logic analyser at the moment to observe the communication)&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;background-color:#cacaca;border:1px solid black;"&gt; &lt;PRE&gt;&amp;nbsp; static void MPU9150_writeByte(uint8_t address, uint8_t subAddress, uint8_t data)
{
&amp;nbsp;&amp;nbsp; char data_write[2];
&amp;nbsp;&amp;nbsp; char data_read[2];
&amp;nbsp;&amp;nbsp; data_write[0] = subAddress;
&amp;nbsp;&amp;nbsp; data_write[1] = data;
&amp;nbsp;&amp;nbsp; SetupXferRecAndExecute(address, &amp;amp;data_write, 2, data_read,1);
}

&amp;nbsp; static char MPU9150_readByte(uint8_t address, uint8_t subAddress)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; char data[1]; // `data` will store the register data&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; char data_write[1];
&amp;nbsp;&amp;nbsp;&amp;nbsp; data_write[0] = subAddress;
&amp;nbsp;&amp;nbsp;&amp;nbsp; SetupXferRecAndExecute(address, &amp;amp;data_write,1, data, 1);
&amp;nbsp;&amp;nbsp;&amp;nbsp; return data[0]; 
}

&amp;nbsp; static void MPU9150_readBytes(uint8_t address, uint8_t subAddress, uint8_t count, uint8_t * dest)
{&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; int ii;
&amp;nbsp;&amp;nbsp;&amp;nbsp; char data[14];
&amp;nbsp;&amp;nbsp;&amp;nbsp; char data_write[1];
&amp;nbsp;&amp;nbsp;&amp;nbsp; data_write[0] = subAddress;
&amp;nbsp;&amp;nbsp;&amp;nbsp; SetupXferRecAndExecute(address,&amp;amp;data_write,1,data, count);
&amp;nbsp;&amp;nbsp;&amp;nbsp; for(ii = 0; ii &amp;lt; count; ii++) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dest[ii] = data[ii];
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
} 
 &lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;I have attached the communication sequence required by the slave device. But my code is failing on simple WHO_AM_I reading ( returns different values).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Any suggestions how to fix my application?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:05:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-Repeated-start/m-p/513253#M85</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:05:19Z</dc:date>
    </item>
    <item>
      <title>Re: I2C Repeated start</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-Repeated-start/m-p/513254#M86</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by NXP_Paul on Wed Oct 29 07:08:16 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;The attached sequences are standard I2C communications, so these should not cause any issues.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;What do you mean that your code is failing on simple WHO_AM_I tests? I am not sure I understand what you are trying to accomplish.&amp;nbsp; I assume you are trying to read back a specific register, and receive a specific response, but please confirm.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;What is the result returned by the I2C functions (is there a NACK, or other error conditions)?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Paul&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:05:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-Repeated-start/m-p/513254#M86</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:05:20Z</dc:date>
    </item>
    <item>
      <title>Re: I2C Repeated start</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-Repeated-start/m-p/513255#M87</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by bobi-one on Wed Oct 29 07:52:20 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Writing to the WHO_I_M register of the slave doesn't return the expected value( only a couple of times actually did), so i presume the communication with it is not&amp;nbsp; working correctly. I did not observe any error conditions from the I2C .&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:05:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-Repeated-start/m-p/513255#M87</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:05:21Z</dc:date>
    </item>
    <item>
      <title>Re: I2C Repeated start</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-Repeated-start/m-p/513256#M88</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by NXP_Paul on Wed Oct 29 08:28:22 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;The fact that you're getting values back from the slave device, and there are no I2C errors reported is a good sign.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Now the question is whether the software is corrupting the values, or is the data on the bus not what you really expected.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You really need to get a scope and observe what is being transmitted on the bus.&amp;nbsp; I prefer a scope to a logic analyzer for looking at the I2C bus since it provides much more detail.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Paul&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:05:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-Repeated-start/m-p/513256#M88</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:05:21Z</dc:date>
    </item>
    <item>
      <title>Re: I2C Repeated start</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-Repeated-start/m-p/513257#M89</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by LabRat on Wed Oct 29 08:52:28 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I2C protocol of MPU-9150 doesn't look exotic&amp;nbsp; :) &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Would suggest to [color=#f00]read[/color] WHO_AM_I register (Type: Read Only)...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:05:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-Repeated-start/m-p/513257#M89</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:05:22Z</dc:date>
    </item>
    <item>
      <title>Re: I2C Repeated start</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-Repeated-start/m-p/513258#M90</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 Wed Oct 29 13:01:39 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: bobi-one&lt;/STRONG&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;&amp;nbsp; static void MPU9150_writeByte(uint8_t address, uint8_t subAddress, uint8_t data)
{
&amp;nbsp;&amp;nbsp; char data_write[2];
&amp;nbsp;&amp;nbsp; char data_read[2];
&amp;nbsp;&amp;nbsp; data_write[0] = subAddress;
&amp;nbsp;&amp;nbsp; data_write[1] = data;
&amp;nbsp;&amp;nbsp; SetupXferRecAndExecute(address, &amp;amp;data_write, 2, data_read,1);
}

&amp;nbsp; static char MPU9150_readByte(uint8_t address, uint8_t subAddress)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; char data[1]; // `data` will store the register data&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; char data_write[1];
&amp;nbsp;&amp;nbsp;&amp;nbsp; data_write[0] = subAddress;
&amp;nbsp;&amp;nbsp;&amp;nbsp; SetupXferRecAndExecute(address, &amp;amp;data_write,1, data, 1);
&amp;nbsp;&amp;nbsp;&amp;nbsp; return data[0]; 
}

&amp;nbsp; static void MPU9150_readBytes(uint8_t address, uint8_t subAddress, uint8_t count, uint8_t * dest)
{&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; int ii;
&amp;nbsp;&amp;nbsp;&amp;nbsp; char data[14];
&amp;nbsp;&amp;nbsp;&amp;nbsp; char data_write[1];
&amp;nbsp;&amp;nbsp;&amp;nbsp; data_write[0] = subAddress;
&amp;nbsp;&amp;nbsp;&amp;nbsp; SetupXferRecAndExecute(address,&amp;amp;data_write,1,data, count);
&amp;nbsp;&amp;nbsp;&amp;nbsp; for(ii = 0; ii &amp;lt; count; ii++) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dest[ii] = data[ii];
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
} 
 &lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And no errors or warnings from the compiler? At the first glance&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;amp;data_write&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;is wrong; must be only&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;data_write&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;because data_write is an array like data_read.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:05:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-Repeated-start/m-p/513258#M90</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:05:23Z</dc:date>
    </item>
    <item>
      <title>Re: I2C Repeated start</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-Repeated-start/m-p/513259#M91</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by LabRat on Wed Oct 29 19:32:19 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;It's not very difficult to use own functions with this sample...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As sample I've added EEPROM access functions.&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
//EEPROM access
#define BUFF_SIZE 64
uint8_t tx_buff[BUFF_SIZE];
uint8_t rx_buff[BUFF_SIZE];
uint8_t tx_data[BUFF_SIZE];
uint16_t address;
uint16_t len;

//read bytes from address
static int read_address(uint16_t address, uint16_t bytes)
{
 tx_buff[0] = (address &amp;gt;&amp;gt; 8) &amp;amp; 0xFF;
 tx_buff[1] =&amp;nbsp; address &amp;amp; 0xFF;
[color=#f00] SetupXferRecAndExecute(I2C_ADDR_7BIT, &amp;amp;tx_buff[0], 2, &amp;amp;rx_buff[0], bytes);[/color]
 if (i2cmXferRec.status == I2CM_STATUS_OK)
 {
&amp;nbsp; return 1;
 }
 return 0;
}

//write bytes to address
static int write_address(uint16_t address, uint16_t bytes)
{
 tx_buff[0] = (address &amp;gt;&amp;gt; 8) &amp;amp; 0xFF;
 tx_buff[1] =&amp;nbsp; address &amp;amp; 0xFF;
 memcpy(&amp;amp;tx_buff[2],&amp;amp;tx_data[0],bytes);
 [color=#f00]SetupXferRecAndExecute(I2C_ADDR_7BIT, &amp;amp;tx_buff[0], bytes+2, &amp;amp;rx_buff[0], 0);[/color]
 if (i2cmXferRec.status == I2CM_STATUS_OK)
 {
&amp;nbsp; return 1;
 }
 return 0;
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
//write data
tx_data[0] = 0x12;
tx_data[1] = 0x34;
tx_data[2] = 0x56;
tx_data[3] = 0x78;
address = 0x10;
len = 4;
ret = write_address(address,len);
printf("Write Data to Address&amp;nbsp; 0x%04X-",address);
if(ret)printf("Success ");
else printf("Error ");
for(i=0; i &amp;lt; len; i++){printf("%02X ",tx_data&lt;I&gt;);}
printf("\n");
&lt;/I&gt;&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;
//read data
address = 0x10;
len = 4;
ret = read_address(address,len);
printf("Read Data from Address 0x%04X-",address);
if(ret)printf("Success ");
else printf("Error ");
for(i=0; i &amp;lt; len; i++){printf("%02X ",rx_buff&lt;I&gt;);}
printf("\n");
&lt;/I&gt;&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;SPAN&gt;This EEPROM sample is accessing data bytes with a [color=#f00]2 byte address[/color].&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think MPU-9150 is accessing registers with 1 byte. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So a register write function should transmit 2 bytes (register_address + data) and receive 0.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;A register read function should transmit 1 byte (register address) and receive 1 byte (data).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Usually SetupXferRecAndExecute is doing everything what's necessary, you just have to fill the buffers and use the correct I2C 7bit address... &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:05:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-Repeated-start/m-p/513259#M91</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:05:23Z</dc:date>
    </item>
    <item>
      <title>Re: I2C Repeated start</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-Repeated-start/m-p/513260#M92</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by bobi-one on Fri Oct 31 01:34:24 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;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: bobi-one&lt;/STRONG&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;&amp;nbsp; static void MPU9150_writeByte(uint8_t address, uint8_t subAddress, uint8_t data)
{
&amp;nbsp;&amp;nbsp; char data_write[2];
&amp;nbsp;&amp;nbsp; char data_read[2];
&amp;nbsp;&amp;nbsp; data_write[0] = subAddress;
&amp;nbsp;&amp;nbsp; data_write[1] = data;
&amp;nbsp;&amp;nbsp; SetupXferRecAndExecute(address, &amp;amp;data_write, 2, data_read,1);
}

&amp;nbsp; static char MPU9150_readByte(uint8_t address, uint8_t subAddress)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; char data[1]; // `data` will store the register data&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; char data_write[1];
&amp;nbsp;&amp;nbsp;&amp;nbsp; data_write[0] = subAddress;
&amp;nbsp;&amp;nbsp;&amp;nbsp; SetupXferRecAndExecute(address, &amp;amp;data_write,1, data, 1);
&amp;nbsp;&amp;nbsp;&amp;nbsp; return data[0]; 
}

&amp;nbsp; static void MPU9150_readBytes(uint8_t address, uint8_t subAddress, uint8_t count, uint8_t * dest)
{&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; int ii;
&amp;nbsp;&amp;nbsp;&amp;nbsp; char data[14];
&amp;nbsp;&amp;nbsp;&amp;nbsp; char data_write[1];
&amp;nbsp;&amp;nbsp;&amp;nbsp; data_write[0] = subAddress;
&amp;nbsp;&amp;nbsp;&amp;nbsp; SetupXferRecAndExecute(address,&amp;amp;data_write,1,data, count);
&amp;nbsp;&amp;nbsp;&amp;nbsp; for(ii = 0; ii &amp;lt; count; ii++) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dest[ii] = data[ii];
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
} 
 &lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;And no errors or warnings from the compiler? At the first glance&lt;BR /&gt;&amp;amp;data_write&lt;BR /&gt;is wrong; must be only&lt;BR /&gt;data_write&lt;BR /&gt;because data_write is an array like data_read.&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Oh, i just noticed those ampersands ( there was even a warning).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I believe the functions work and all the problems are cause because of the data coming from the sensor.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Have somebody else worked with MPU9150? Because the driver I am familiar with is for linux kernel and it is hard to interface just like that?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Boyko&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:05:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-Repeated-start/m-p/513260#M92</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:05:24Z</dc:date>
    </item>
    <item>
      <title>Re: I2C Repeated start</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-Repeated-start/m-p/513261#M93</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 Sun Nov 02 07:18:41 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;I believe the functions work and all the problems are cause because of the data coming from the sensor. &lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Well, of course Sunday is the day to believe, but when your parameter is definately wrong...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;And 'data_write' and '&amp;amp;data_write[0]' is the same in C, just for clarification. Have a look at the C-book of your choice; chapter 'arrays and strings' or so.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Using an address instead of a value cannot 'work' (and vice versa).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:05:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-Repeated-start/m-p/513261#M93</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:05:24Z</dc:date>
    </item>
  </channel>
</rss>

