<?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中的主题 LPC1549 I2C question</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1549-I2C-question/m-p/933923#M37191</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I am a newbie in I2C so please be patient.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;I am using the example code or the I2C master interrupt mode of LPCopen on the OM13056 Evalboard (LPC1549 processor).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;I want to communicate with a&amp;nbsp;LSM9DS1 gyroscope-accelerometer-magnetometer sensor.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;With the functions of the examples I managed to establish the connection between the board and the sensor without errors. The problem is that I can't perform the write operations to the registers of the sensor (which I need to do) neither read some useful data because I think I can't understand the logic of the example code.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;These are the two crucial example functions.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;In the ReadTemperatureI2CM() when it is called SetupXferRecAndExecute(..) the first function argument is the slave address (previously defined), the second one I think is the sensor's temperature-register address, the third is the number of bytes to send, the fourth is where do the data (received from the slave) are saved, and the last is the number of bytes to receive.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;If I run this code I always get this output on Realterm "&lt;SPAN style="color: #3d3d3d; background-color: #f6f6f6;"&gt;Temperature read over I2C is 64 degrees C.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;" It doesn't change even if I "heat" the sensor.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;I think I have to initialize the sensor specification by doing some write operations to the sensor registers.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;How can I write on a specific slave register? Is this "&lt;SPAN style="color: #3d3d3d; background-color: #f6f6f6;"&gt;SetupXferRecAndExecute&lt;/SPAN&gt;"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&amp;nbsp;funtion the one I need?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;Thanks to everyone who will help me.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;static void SetupXferRecAndExecute(uint8_t devAddr,uint8_t *txBuffPtr,uint16_t txSize,uint8_t *rxBuffPtr,uint16_t rxSize)&lt;BR /&gt;{&lt;BR /&gt; /* Setup I2C transfer record */&lt;BR /&gt; i2cmXferRec.slaveAddr = devAddr;&lt;BR /&gt; i2cmXferRec.status = 0;&lt;BR /&gt; i2cmXferRec.txSz = txSize;&lt;BR /&gt; i2cmXferRec.rxSz = rxSize;&lt;BR /&gt; i2cmXferRec.txBuff = txBuffPtr;&lt;BR /&gt; i2cmXferRec.rxBuff = rxBuffPtr;&lt;/P&gt;&lt;P&gt;Chip_I2CM_Xfer(LPC_I2C0, &amp;amp;i2cmXferRec);&lt;BR /&gt; /* Enable Master Interrupts */&lt;BR /&gt; Chip_I2C_EnableInt(LPC_I2C0, I2C_INTENSET_MSTPENDING | I2C_INTENSET_MSTRARBLOSS | I2C_INTENSET_MSTSTSTPERR);&lt;BR /&gt; /* Wait for transfer completion */&lt;BR /&gt; WaitForI2cXferComplete(&amp;amp;i2cmXferRec);&lt;BR /&gt; /* Clear all Interrupts */&lt;BR /&gt; Chip_I2C_ClearInt(LPC_I2C0, I2C_INTENSET_MSTPENDING | I2C_INTENSET_MSTRARBLOSS | I2C_INTENSET_MSTSTSTPERR);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;static void ReadTemperatureI2CM(void)&lt;BR /&gt;{&lt;BR /&gt; uint8_t temperature;&lt;BR /&gt; uint8_t lm75TempRegisterAddress = (0x15);&lt;/P&gt;&lt;P&gt;/* Read LM75 temperature sensor */&lt;BR /&gt; SetupXferRecAndExecute(&lt;/P&gt;&lt;P&gt;/* The LM75 I2C bus address */&lt;BR /&gt; I2C_TEMP_ADDR_7BIT,&lt;/P&gt;&lt;P&gt;/* Transmit one byte, the LM75 temp register address */&lt;BR /&gt; &amp;amp;lm75TempRegisterAddress, 1,&lt;/P&gt;&lt;P&gt;/* Receive back two bytes, the contents of the temperature register */&lt;BR /&gt; &amp;amp;temperature, 2);&lt;/P&gt;&lt;P&gt;/* Test for valid operation */&lt;BR /&gt; if (i2cmXferRec.status == I2CM_STATUS_OK) {&lt;BR /&gt; /* Output temperature. */&lt;BR /&gt; DEBUGOUT("Temperature read over I2C is %d degrees C.\r\n",&lt;BR /&gt; (int) temperature);&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; DEBUGOUT("Error %d reading temperature.\r\n", i2cmXferRec.status );&lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 31 May 2019 15:26:28 GMT</pubDate>
    <dc:creator>fabrizio_bordi</dc:creator>
    <dc:date>2019-05-31T15:26:28Z</dc:date>
    <item>
      <title>LPC1549 I2C question</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1549-I2C-question/m-p/933923#M37191</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I am a newbie in I2C so please be patient.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;I am using the example code or the I2C master interrupt mode of LPCopen on the OM13056 Evalboard (LPC1549 processor).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;I want to communicate with a&amp;nbsp;LSM9DS1 gyroscope-accelerometer-magnetometer sensor.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;With the functions of the examples I managed to establish the connection between the board and the sensor without errors. The problem is that I can't perform the write operations to the registers of the sensor (which I need to do) neither read some useful data because I think I can't understand the logic of the example code.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;These are the two crucial example functions.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;In the ReadTemperatureI2CM() when it is called SetupXferRecAndExecute(..) the first function argument is the slave address (previously defined), the second one I think is the sensor's temperature-register address, the third is the number of bytes to send, the fourth is where do the data (received from the slave) are saved, and the last is the number of bytes to receive.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;If I run this code I always get this output on Realterm "&lt;SPAN style="color: #3d3d3d; background-color: #f6f6f6;"&gt;Temperature read over I2C is 64 degrees C.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;" It doesn't change even if I "heat" the sensor.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;I think I have to initialize the sensor specification by doing some write operations to the sensor registers.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;How can I write on a specific slave register? Is this "&lt;SPAN style="color: #3d3d3d; background-color: #f6f6f6;"&gt;SetupXferRecAndExecute&lt;/SPAN&gt;"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&amp;nbsp;funtion the one I need?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;Thanks to everyone who will help me.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;static void SetupXferRecAndExecute(uint8_t devAddr,uint8_t *txBuffPtr,uint16_t txSize,uint8_t *rxBuffPtr,uint16_t rxSize)&lt;BR /&gt;{&lt;BR /&gt; /* Setup I2C transfer record */&lt;BR /&gt; i2cmXferRec.slaveAddr = devAddr;&lt;BR /&gt; i2cmXferRec.status = 0;&lt;BR /&gt; i2cmXferRec.txSz = txSize;&lt;BR /&gt; i2cmXferRec.rxSz = rxSize;&lt;BR /&gt; i2cmXferRec.txBuff = txBuffPtr;&lt;BR /&gt; i2cmXferRec.rxBuff = rxBuffPtr;&lt;/P&gt;&lt;P&gt;Chip_I2CM_Xfer(LPC_I2C0, &amp;amp;i2cmXferRec);&lt;BR /&gt; /* Enable Master Interrupts */&lt;BR /&gt; Chip_I2C_EnableInt(LPC_I2C0, I2C_INTENSET_MSTPENDING | I2C_INTENSET_MSTRARBLOSS | I2C_INTENSET_MSTSTSTPERR);&lt;BR /&gt; /* Wait for transfer completion */&lt;BR /&gt; WaitForI2cXferComplete(&amp;amp;i2cmXferRec);&lt;BR /&gt; /* Clear all Interrupts */&lt;BR /&gt; Chip_I2C_ClearInt(LPC_I2C0, I2C_INTENSET_MSTPENDING | I2C_INTENSET_MSTRARBLOSS | I2C_INTENSET_MSTSTSTPERR);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;static void ReadTemperatureI2CM(void)&lt;BR /&gt;{&lt;BR /&gt; uint8_t temperature;&lt;BR /&gt; uint8_t lm75TempRegisterAddress = (0x15);&lt;/P&gt;&lt;P&gt;/* Read LM75 temperature sensor */&lt;BR /&gt; SetupXferRecAndExecute(&lt;/P&gt;&lt;P&gt;/* The LM75 I2C bus address */&lt;BR /&gt; I2C_TEMP_ADDR_7BIT,&lt;/P&gt;&lt;P&gt;/* Transmit one byte, the LM75 temp register address */&lt;BR /&gt; &amp;amp;lm75TempRegisterAddress, 1,&lt;/P&gt;&lt;P&gt;/* Receive back two bytes, the contents of the temperature register */&lt;BR /&gt; &amp;amp;temperature, 2);&lt;/P&gt;&lt;P&gt;/* Test for valid operation */&lt;BR /&gt; if (i2cmXferRec.status == I2CM_STATUS_OK) {&lt;BR /&gt; /* Output temperature. */&lt;BR /&gt; DEBUGOUT("Temperature read over I2C is %d degrees C.\r\n",&lt;BR /&gt; (int) temperature);&lt;BR /&gt; }&lt;BR /&gt; else {&lt;BR /&gt; DEBUGOUT("Error %d reading temperature.\r\n", i2cmXferRec.status );&lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 May 2019 15:26:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1549-I2C-question/m-p/933923#M37191</guid>
      <dc:creator>fabrizio_bordi</dc:creator>
      <dc:date>2019-05-31T15:26:28Z</dc:date>
    </item>
    <item>
      <title>Re: LPC1549 I2C question</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1549-I2C-question/m-p/933924#M37192</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Fabrizio,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you mention, those are functions you have to pay attention to in order to write to a specific register in your sensor. I recommend you to check on the sensor side of there is any initialization needed in order to start sensing the temperature.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Felipe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Jun 2019 21:53:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1549-I2C-question/m-p/933924#M37192</guid>
      <dc:creator>FelipeGarcia</dc:creator>
      <dc:date>2019-06-03T21:53:00Z</dc:date>
    </item>
  </channel>
</rss>

