<?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 example problem LPC1549</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-example-problem-LPC1549/m-p/562194#M16439</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh i forgot the interrupt service routine:&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14666007810078889" data-renderedposition="34_8_1192_64" jivemacro_uid="_14666007810078889"&gt;&lt;P&gt;void I2C0_IRQHandler(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; Chip_I2CM_XferHandler(LPC_I2C0, &amp;amp;I2C_Xfer);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 22 Jun 2016 13:06:36 GMT</pubDate>
    <dc:creator>pat_wit</dc:creator>
    <dc:date>2016-06-22T13:06:36Z</dc:date>
    <item>
      <title>I2C example problem LPC1549</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-example-problem-LPC1549/m-p/562193#M16438</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi guys,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i wasn't sure if this belongs to the LPCOpen or the LPC15xx forum.&lt;/P&gt;&lt;P&gt;I got the following problem:&lt;/P&gt;&lt;P&gt;I am using the example code or the I2C master interrupt mode of LPCopen on the OM13056 Evalboard (LPC1549 processor). The configuration of the I2C stays the same like the example (Clk_Div = 40 -&amp;gt; 72MHz/40 = 1.8MHz,Bus Speed = 100kHz). In the operation i just want to read 2 Bytes of data (no writing).&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The init function:&lt;/P&gt;&lt;PRE class="c++" name="code"&gt;void Init_I2C_Drucksensor(void) { &amp;nbsp; I2C_Xfer.slaveAddr = AG4_Sens_ADR; //Adr. des sensor &amp;nbsp; I2C_Xfer.status = 0; //Status auf 0 &amp;nbsp; I2C_Xfer.txSz = 0; //es wird nichts geschrieben &amp;nbsp; I2C_Xfer.txBuff = NULL; //Buffer fürs schreiben auf null zeigen&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; Chip_IOCON_PinMuxSet(LPC_IOCON, PORT_0, PIN_22, (IOCON_DIGMODE_EN | I2C_Mode)); &amp;nbsp; Chip_IOCON_PinMuxSet(LPC_IOCON, PORT_0, PIN_23, (IOCON_DIGMODE_EN | I2C_Mode)); &amp;nbsp; Chip_SWM_EnableFixedPin(SWM_FIXED_I2C0_SCL); &amp;nbsp; Chip_SWM_EnableFixedPin(SWM_FIXED_I2C0_SDA);&amp;nbsp;&amp;nbsp; &amp;nbsp; Chip_I2C_Init(LPC_I2C0);&amp;nbsp;&amp;nbsp; &amp;nbsp; Chip_I2C_SetClockDiv(LPC_I2C0, I2C_CLK_Div);&amp;nbsp;&amp;nbsp; &amp;nbsp; //Chip_I2CM_SetBusSpeed(LPC_I2C0, I2C_400kHz_Speed); &amp;nbsp; Chip_I2CM_SetBusSpeed(LPC_I2C0, I2C_100kHz_Speed);&amp;nbsp;&amp;nbsp; &amp;nbsp; Chip_I2CM_Enable(LPC_I2C0);&amp;nbsp;&amp;nbsp; &amp;nbsp; NVIC_EnableIRQ(I2C0_IRQn); &amp;nbsp; NVIC_ClearPendingIRQ(I2C0_IRQn); }&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The function to read out the data:&lt;/P&gt;&lt;PRE class="plain" name="code"&gt;uint16_t ReadPres(void)&amp;nbsp; { uint8_t RohDaten[Pressure_Data_Size], StatusVal; uint16_t Pressure = 0, Buffer = 0;;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Auslesen des Sensors via I2C&amp;nbsp;&amp;nbsp;&amp;nbsp; I2C_Xfer.rxSz = Pressure_Data_Size;&amp;nbsp; //Menge an empfangenen Bytes&amp;nbsp; I2C_Xfer.rxBuff = RohDaten;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Buffer zum empfangen&amp;nbsp;&amp;nbsp;&amp;nbsp; #ifndef I2C_Polling_Mode&amp;nbsp;&amp;nbsp; Chip_I2CM_Xfer(LPC_I2C0, &amp;amp;I2C_Xfer); Chip_I2C_EnableInt(LPC_I2C0, (I2C_INTENSET_MSTPENDING | I2C_INTENSET_MSTRARBLOSS | I2C_INTENSET_MSTSTSTPERR));&amp;nbsp;&amp;nbsp; while (I2C_Xfer.status == I2CM_STATUS_BUSY) {__WFI();}&amp;nbsp;&amp;nbsp; Chip_I2C_ClearInt(LPC_I2C0, (I2C_INTENSET_MSTPENDING | I2C_INTENSET_MSTRARBLOSS | I2C_INTENSET_MSTSTSTPERR));&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #else&amp;nbsp;&amp;nbsp;&amp;nbsp; Chip_I2CM_XferBlocking(LPC_I2C0, &amp;amp;I2C_Xfer);&amp;nbsp;&amp;nbsp;&amp;nbsp; //ReadI2C(AG4_Sens_ADR, RohDaten, Pressure_Data_Size);&amp;nbsp;&amp;nbsp; #endif&amp;nbsp;&amp;nbsp; //Verarbeiten der Daten&amp;nbsp;&amp;nbsp; StatusVal = (RohDaten[0]&amp;gt;&amp;gt;6) &amp;amp; 0x03;&amp;nbsp;&amp;nbsp; if(StatusVal == 0)&amp;nbsp; {&amp;nbsp; Buffer = ((RohDaten[0]&amp;lt;&amp;lt;8) | (RohDaten[1])) &amp;amp; 0x3FFF;&amp;nbsp; Pressure = Buffer*3 + (Buffer/10)*3 + (Buffer/100)*9 + (Buffer/1000)*1;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }else{&amp;nbsp;&amp;nbsp;&amp;nbsp; Buffer = ((RohDaten[0]&amp;lt;&amp;lt;8) | (RohDaten[1])) &amp;amp; 0xC000;&amp;nbsp; //Rückgabe der Fehlermeldung&amp;nbsp;&amp;nbsp;&amp;nbsp; Pressure = Buffer;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp; return Pressure; }&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The sampling rate is controlled by the RIT (Interrupt every 1ms -&amp;gt; all 10ms getting a new sample).&lt;/P&gt;&lt;P&gt;I tried the code in interrupt mode (default) and in polling mode.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In interrupt mode i stuck at the line in the reading function:&lt;/P&gt;&lt;PRE class="plain" name="code"&gt;while (I2C_Xfer.status == I2CM_STATUS_BUSY) {__WFI();}&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At the polling mode at the line where the status gets requested.&lt;/P&gt;&lt;P&gt;If i meassure on the Pins there is no activity. So i think the data is never written and that's the reason why the status never changes to OK or something else.&lt;/P&gt;&lt;P&gt;But i don't have any idea why this is so, so i appreciate all kind of help/information.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;Patrick&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jun 2016 12:49:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-example-problem-LPC1549/m-p/562193#M16438</guid>
      <dc:creator>pat_wit</dc:creator>
      <dc:date>2016-06-22T12:49:53Z</dc:date>
    </item>
    <item>
      <title>Re: I2C example problem LPC1549</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-example-problem-LPC1549/m-p/562194#M16439</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh i forgot the interrupt service routine:&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14666007810078889" data-renderedposition="34_8_1192_64" jivemacro_uid="_14666007810078889"&gt;&lt;P&gt;void I2C0_IRQHandler(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; Chip_I2CM_XferHandler(LPC_I2C0, &amp;amp;I2C_Xfer);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jun 2016 13:06:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-example-problem-LPC1549/m-p/562194#M16439</guid>
      <dc:creator>pat_wit</dc:creator>
      <dc:date>2016-06-22T13:06:36Z</dc:date>
    </item>
    <item>
      <title>Re: I2C example problem LPC1549</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-example-problem-LPC1549/m-p/562195#M16440</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;i found the error. It was necessary to call the function &lt;EM&gt;Chip_SWM_Init();&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jun 2016 13:39:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/I2C-example-problem-LPC1549/m-p/562195#M16440</guid>
      <dc:creator>pat_wit</dc:creator>
      <dc:date>2016-06-22T13:39:10Z</dc:date>
    </item>
  </channel>
</rss>

