<?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>8-bit Microcontrollersのトピックi2c on MK10DX128VLH7</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/i2c-on-MK10DX128VLH7/m-p/731896#M22504</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey there,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am struggling with setting up the i2c interface on my MK10DX128VLH7 microprocessor.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently I am using KDS to code, but I'm not using Processor Expert.&lt;/P&gt;&lt;P&gt;Could anybody provide an example on how to setup and send 3&amp;nbsp;data bytes? The MCU should be the master. I want to send 3 bytes (address+data+data). I thought that shouldn't be that difficult...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I basically did the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;SIM_SCGC4 |= SIM_SCGC4_I2C1_MASK; &lt;SPAN style="color: #4e9072;"&gt;//Turn on clock to I2C1 module&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&lt;/P&gt;&lt;P style="color: #4e9072; font-size: 11px;"&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;/* configure GPIO for I2C1 function*/&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&amp;nbsp; &amp;nbsp; SIM_SCGC5 |= SIM_SCGC5_PORTE_MASK;&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&amp;nbsp; &amp;nbsp; PORTE_PCR0 = PORT_PCR_MUX(0x06);&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&amp;nbsp; &amp;nbsp; PORTE_PCR1 = PORT_PCR_MUX(0x06);&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&lt;/P&gt;&lt;P style="color: #4e9072; font-size: 11px;"&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;/* set MULT and ICR -&amp;gt; S.1141&amp;nbsp; */&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&amp;nbsp; &amp;nbsp; I2C1_F = 0x14;&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #4e9072; font-size: 11px;"&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;//I2C1_C1 = I2C_C1_IICEN_MASK; &amp;nbsp; &amp;nbsp; &amp;nbsp; /* enable IIC */&lt;/P&gt;&lt;P style="color: #4e9072; font-size: 11px;"&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp; &amp;nbsp; I2C1_C1 = 0x80u; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;/* s1142 enable IIC - &lt;SPAN style="text-decoration: underline;"&gt;Feld&lt;/SPAN&gt; 7 */&lt;/P&gt;&lt;P style="color: #4e9072; font-size: 11px;"&gt;&lt;/P&gt;&lt;P style="color: #4e9072; font-size: 11px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;/* send start signal */&lt;/P&gt;&lt;P style="color: #4e9072; font-size: 11px;"&gt;&lt;SPAN style="color: #000000;"&gt;&lt;SPAN class=""&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;I2C1_C1 |= 0x10;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;I2C1_C1 |= I2C_C1_MST_MASK;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&lt;/P&gt;&lt;P style="color: #4e9072; font-size: 11px;"&gt;&lt;SPAN style="color: #000000;"&gt;&lt;SPAN class=""&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;/* send ID with W/R bit */&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&lt;SPAN class=""&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;i2c_write(SlaveID);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&amp;nbsp;&amp;nbsp;//wait&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;while((I2C1_S &amp;amp; I2C_S_IICIF_MASK)==0) {};&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;I2C1_S |= I2C_S_IICIF_MASK;&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// send data byte&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;I2C1_D = data;&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// send stop&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;I2C1_C1 &amp;amp;= ~I2C_C1_MST_MASK;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;I2C1_C1 &amp;amp;= ~I2C_C1_TX_MASK;&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;With this code, I hoped to transmit one byte, am I missing something?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 23 Mar 2018 16:12:43 GMT</pubDate>
    <dc:creator>hipsel</dc:creator>
    <dc:date>2018-03-23T16:12:43Z</dc:date>
    <item>
      <title>i2c on MK10DX128VLH7</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/i2c-on-MK10DX128VLH7/m-p/731896#M22504</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey there,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am struggling with setting up the i2c interface on my MK10DX128VLH7 microprocessor.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently I am using KDS to code, but I'm not using Processor Expert.&lt;/P&gt;&lt;P&gt;Could anybody provide an example on how to setup and send 3&amp;nbsp;data bytes? The MCU should be the master. I want to send 3 bytes (address+data+data). I thought that shouldn't be that difficult...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I basically did the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;SIM_SCGC4 |= SIM_SCGC4_I2C1_MASK; &lt;SPAN style="color: #4e9072;"&gt;//Turn on clock to I2C1 module&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&lt;/P&gt;&lt;P style="color: #4e9072; font-size: 11px;"&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;/* configure GPIO for I2C1 function*/&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&amp;nbsp; &amp;nbsp; SIM_SCGC5 |= SIM_SCGC5_PORTE_MASK;&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&amp;nbsp; &amp;nbsp; PORTE_PCR0 = PORT_PCR_MUX(0x06);&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&amp;nbsp; &amp;nbsp; PORTE_PCR1 = PORT_PCR_MUX(0x06);&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&lt;/P&gt;&lt;P style="color: #4e9072; font-size: 11px;"&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;/* set MULT and ICR -&amp;gt; S.1141&amp;nbsp; */&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&amp;nbsp; &amp;nbsp; I2C1_F = 0x14;&lt;SPAN class=""&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #4e9072; font-size: 11px;"&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;//I2C1_C1 = I2C_C1_IICEN_MASK; &amp;nbsp; &amp;nbsp; &amp;nbsp; /* enable IIC */&lt;/P&gt;&lt;P style="color: #4e9072; font-size: 11px;"&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp; &amp;nbsp; I2C1_C1 = 0x80u; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;/* s1142 enable IIC - &lt;SPAN style="text-decoration: underline;"&gt;Feld&lt;/SPAN&gt; 7 */&lt;/P&gt;&lt;P style="color: #4e9072; font-size: 11px;"&gt;&lt;/P&gt;&lt;P style="color: #4e9072; font-size: 11px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;/* send start signal */&lt;/P&gt;&lt;P style="color: #4e9072; font-size: 11px;"&gt;&lt;SPAN style="color: #000000;"&gt;&lt;SPAN class=""&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;I2C1_C1 |= 0x10;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;I2C1_C1 |= I2C_C1_MST_MASK;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&lt;/P&gt;&lt;P style="color: #4e9072; font-size: 11px;"&gt;&lt;SPAN style="color: #000000;"&gt;&lt;SPAN class=""&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;/* send ID with W/R bit */&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&lt;SPAN class=""&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;i2c_write(SlaveID);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&amp;nbsp;&amp;nbsp;//wait&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;while((I2C1_S &amp;amp; I2C_S_IICIF_MASK)==0) {};&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;I2C1_S |= I2C_S_IICIF_MASK;&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// send data byte&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;I2C1_D = data;&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;// send stop&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;I2C1_C1 &amp;amp;= ~I2C_C1_MST_MASK;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;I2C1_C1 &amp;amp;= ~I2C_C1_TX_MASK;&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;&lt;/P&gt;&lt;P style="font-size: 11px;"&gt;With this code, I hoped to transmit one byte, am I missing something?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Mar 2018 16:12:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/i2c-on-MK10DX128VLH7/m-p/731896#M22504</guid>
      <dc:creator>hipsel</dc:creator>
      <dc:date>2018-03-23T16:12:43Z</dc:date>
    </item>
  </channel>
</rss>

