<?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 Re: kl25 I2C_HAL_WriteByte() in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/kl25-I2C-HAL-WriteByte/m-p/476386#M29014</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, Jorge.&lt;/P&gt;&lt;P&gt;thank you very much for your replay.&lt;/P&gt;&lt;P&gt;I have done the exactly same test as you do and realized that. I am trying to use more the hall and drive function present at the KSDK. But for many reasons i like to make my own rotines and for that i read the reference manual.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It would save a lot of time if there was a better documentations regarding this. If you read the manual and intend to make a pooling rotine TC would be the choice but does not work as documented.&lt;/P&gt;&lt;P&gt;here is the rotine i made to read the MMA8451. hope this help people with the same problem&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="_jivemacro_uid_14581748091115131 jive_macro_code jive_text_macro" data-renderedposition="242_8_1162_528" jivemacro_uid="_14581748091115131"&gt;&lt;P&gt;unsigned char Read_MMA8451Q_I2C(unsigned char address,unsigned char *buffer,unsigned char qtd)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; unsigned char cnt_i2c;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; while((I2C0_S &amp;amp; I2C_S_TCF_MASK )==0){}&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_SetDirMode(I2C0,1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_SendStart(I2C0);&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_S |= I2C_S_IICIF_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_WriteByte(I2C0,I2C_MMA8451Q_ADD | I2C_WR);&lt;/P&gt;&lt;P&gt;&amp;nbsp; while((I2C0_S &amp;amp; I2C_S_IICIF_MASK)==0){}&lt;/P&gt;&lt;P&gt;&amp;nbsp; if ((I2C0_S &amp;amp; I2C_S_RXAK_MASK) != 0) return(0);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_S |= I2C_S_IICIF_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_WriteByte(I2C0,(address));&lt;/P&gt;&lt;P&gt;&amp;nbsp; while((I2C0_S &amp;amp; I2C_S_IICIF_MASK)==0){}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_SendStart(I2C0);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_S |= I2C_S_IICIF_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_WriteByte(I2C0,I2C_MMA8451Q_ADD | I2C_RD);&lt;/P&gt;&lt;P&gt;&amp;nbsp; while((I2C0_S &amp;amp; I2C_S_IICIF_MASK)==0){}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_SetDirMode(I2C0,0);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_SendAck(I2C0);&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_S |= I2C_S_IICIF_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; (void)I2C_HAL_ReadByte(I2C0);&lt;/P&gt;&lt;P&gt;&amp;nbsp; while((I2C0_S &amp;amp; I2C_S_IICIF_MASK)==0){}&lt;/P&gt;&lt;P&gt;&amp;nbsp; for (cnt_i2c=0 ; cnt_i2c != qtd; ++ cnt_i2c)&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; while((I2C0_S &amp;amp; I2C_S_IICIF_MASK)==0){}&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_S |= I2C_S_IICIF_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; buffer[cnt_i2c] = I2C_HAL_ReadByte(I2C0);&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_SendNak(I2C0);&lt;/P&gt;&lt;P&gt;&amp;nbsp; while((I2C0_S &amp;amp; I2C_S_IICIF_MASK)==0){}&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_SendStop(I2C0);&lt;/P&gt;&lt;P&gt;&amp;nbsp; return(1);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 17 Mar 2016 00:38:28 GMT</pubDate>
    <dc:creator>Edrianocarlos</dc:creator>
    <dc:date>2016-03-17T00:38:28Z</dc:date>
    <item>
      <title>kl25 I2C_HAL_WriteByte()</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/kl25-I2C-HAL-WriteByte/m-p/476381#M29009</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello.&lt;/P&gt;&lt;P&gt;I am currently writing an I2c Baremetal function.&lt;/P&gt;&lt;P&gt;and after a long time testing and analyzing the data i could realize that&amp;nbsp;&amp;nbsp; ITCF and&amp;nbsp; RXAK flags does not work as i thought. &lt;/P&gt;&lt;P&gt;after sending a byte to I2c if i try to test either TCF and RXAK both of them are true and i start to overwrite the data register. if i use the code below nothing works. i already found a way to solve that testing the IICIF flag. this one works.&lt;/P&gt;&lt;P&gt;but my question is. doesnot this flags works at all? i am assuming something wrong?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;I2C_HAL_WriteByte(I2C0,0xA0);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;while((I2C0_S &amp;amp; I2C_S_TCF_MASK )==0){}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;I2C_HAL_WriteByte(I2C0,0x00);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;while((I2C0_S &amp;amp; I2C_S_TCF_MASK )==0){}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;I2C_HAL_WriteByte(I2C0,0x00);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;while((I2C0_S &amp;amp; I2C_S_TCF_MASK )==0){}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;also if i use RXAK the same problem occurs &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;I2C_HAL_WriteByte(I2C0,0xA0);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;while((I2C0_S &amp;amp; I2C_S_RXAK_MASK )==0){}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;I2C_HAL_WriteByte(I2C0,0x00);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;while((I2C0_S &amp;amp; I2C_S_RXAK_MASK )==0){}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;I2C_HAL_WriteByte(I2C0,0x00);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;while((I2C0_S &amp;amp; I2C_S_RXAK_MASK )==0){}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;the code below works fine.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; I2C_HAL_SendStart(I2C0);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; I2C0_S |= I2C_S_IICIF_MASK;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; I2C_HAL_WriteByte(I2C0,endereco);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; while((I2C0_S &amp;amp; I2C_S_IICIF_MASK)==0){}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; I2C0_S |= I2C_S_IICIF_MASK;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; I2C_HAL_WriteByte(I2C0,0x00);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; while((I2C0_S &amp;amp; I2C_S_IICIF_MASK)==0){}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; I2C0_S |= I2C_S_IICIF_MASK;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; I2C_HAL_WriteByte(I2C0,0x00);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; while((I2C0_S &amp;amp; I2C_S_IICIF_MASK)==0){}&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Mar 2016 17:08:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/kl25-I2C-HAL-WriteByte/m-p/476381#M29009</guid>
      <dc:creator>Edrianocarlos</dc:creator>
      <dc:date>2016-03-14T17:08:35Z</dc:date>
    </item>
    <item>
      <title>Re: kl25 I2C_HAL_WriteByte()</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/kl25-I2C-HAL-WriteByte/m-p/476382#M29010</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Edriano,&lt;/P&gt;&lt;P&gt;please send me the code of the function &lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 13.3333px;"&gt;I2C_HAL_WriteByte(I2C0,0xA0), or whole code you are working with for I2C communication.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 13.3333px;"&gt;Then I can send you suggestions.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 13.3333px;"&gt;I'm waiting for your answer.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 13.3333px;"&gt;Best Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 13.3333px;"&gt;Stano.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Mar 2016 10:44:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/kl25-I2C-HAL-WriteByte/m-p/476382#M29010</guid>
      <dc:creator>Stano</dc:creator>
      <dc:date>2016-03-15T10:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: kl25 I2C_HAL_WriteByte()</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/kl25-I2C-HAL-WriteByte/m-p/476383#M29011</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Stanislav.&lt;/P&gt;&lt;P&gt;Here is my routine. it is blocking read and now it is working perfect but i had to read the interrupt flag.&lt;/P&gt;&lt;P&gt;My question was aboult why reading he TCF flag it does not work? wasnt this flag for this? &lt;/P&gt;&lt;P&gt;anyway i will share my function that may help others searching for the same thing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14580479122076979" data-renderedposition="138_8_1002_512" jivemacro_uid="_14580479122076979"&gt;&lt;P&gt;void Read_24LC_I2C(unsigned int address,unsigned char *buffer,unsigned char qtd)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; unsigned char cnt_i2c;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; while((I2C0_S &amp;amp; I2C_S_TCF_MASK )==0){}&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_SetDirMode(I2C0,1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_SendStart(I2C0);&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_S |= I2C_S_IICIF_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_WriteByte(I2C0,endereco);&lt;/P&gt;&lt;P&gt;&amp;nbsp; while((I2C0_S &amp;amp; I2C_S_IICIF_MASK)==0){}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_S |= I2C_S_IICIF_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_WriteByte(I2C0,(unsigned char)((address &amp;gt;&amp;gt; 8) &amp;amp; 0X00FF));&lt;/P&gt;&lt;P&gt;&amp;nbsp; while((I2C0_S &amp;amp; I2C_S_IICIF_MASK)==0){}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_S |= I2C_S_IICIF_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_WriteByte(I2C0,(unsigned char)((address) &amp;amp; 0X00FF));&lt;/P&gt;&lt;P&gt;&amp;nbsp; while((I2C0_S &amp;amp; I2C_S_IICIF_MASK)==0){}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_SendStart(I2C0);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_S |= I2C_S_IICIF_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_WriteByte(I2C0,0xA1);&lt;/P&gt;&lt;P&gt;&amp;nbsp; while((I2C0_S &amp;amp; I2C_S_IICIF_MASK)==0){}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_SetDirMode(I2C0,0);&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_SendAck(I2C0);&lt;/P&gt;&lt;P&gt;&amp;nbsp; (void)I2C_HAL_ReadByte(I2C0);&lt;/P&gt;&lt;P&gt;&amp;nbsp; for (cnt_i2c=0 ; cnt_i2c != qtd; ++ cnt_i2c)&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; while((I2C0_S &amp;amp; I2C_S_TCF_MASK )==0){}&lt;/P&gt;&lt;P&gt;&amp;nbsp; buffer[cnt_i2c] = I2C_HAL_ReadByte(I2C0);&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_SendNak(I2C0);&lt;/P&gt;&lt;P&gt;&amp;nbsp; while((I2C0_S &amp;amp; I2C_S_TCF_MASK )==0){}&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_SendStop(I2C0);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Mar 2016 13:18:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/kl25-I2C-HAL-WriteByte/m-p/476383#M29011</guid>
      <dc:creator>Edrianocarlos</dc:creator>
      <dc:date>2016-03-15T13:18:56Z</dc:date>
    </item>
    <item>
      <title>Re: kl25 I2C_HAL_WriteByte()</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/kl25-I2C-HAL-WriteByte/m-p/476384#M29012</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your reply.&lt;/P&gt;&lt;P&gt;When I saw you code, I think the original code for KL25 FRDM board could be very helpful. It is available on web:&lt;/P&gt;&lt;P&gt;&lt;A href="http://cache.nxp.com/files/32bit/software/KL25_SC.exe?fsrch=1&amp;amp;sr=2&amp;amp;pageNum=1" title="http://cache.nxp.com/files/32bit/software/KL25_SC.exe?fsrch=1&amp;amp;sr=2&amp;amp;pageNum=1"&gt;http://cache.nxp.com/files/32bit/software/KL25_SC.exe?fsrch=1&amp;amp;sr=2&amp;amp;pageNum=1&lt;/A&gt; &lt;/P&gt;&lt;P&gt;It is *.exe file and will be unpacked to folder you will point to. Then select this folder and open file "FRDM_KL25ZDemo.eww" in IAR:&lt;/P&gt;&lt;P&gt;c:\....\KL25 Sample Code\kl25_sc_rev8\klxx-sc-baremetal\build\iar\FRDM_KL25ZDemo\&lt;/P&gt;&lt;P&gt;Then look for "project\I2C\hal_i2c.c" file. There are tested routines for I2C communication which you can use in your project.&lt;/P&gt;&lt;P&gt;I think it will help you build your code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Stano.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Mar 2016 15:52:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/kl25-I2C-HAL-WriteByte/m-p/476384#M29012</guid>
      <dc:creator>Stano</dc:creator>
      <dc:date>2016-03-15T15:52:04Z</dc:date>
    </item>
    <item>
      <title>Re: kl25 I2C_HAL_WriteByte()</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/kl25-I2C-HAL-WriteByte/m-p/476385#M29013</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Edriano Araujo:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you will find in most of the I2C projects with Kinetis, in polling mode the &lt;STRONG&gt;IICIF&lt;/STRONG&gt; flag is used instead of the &lt;STRONG&gt;TCF&lt;/STRONG&gt; flag. The reason for this is that &lt;STRONG&gt;TCF&lt;/STRONG&gt; is only valid for a specific period of time during the byte transfer and it is a read only flag. &lt;STRONG&gt;TCF&lt;/STRONG&gt; does not clear immediately after writing to the &lt;STRONG&gt;I2Cx_D&lt;/STRONG&gt; register but until the I2C peripheral starts sending the clock signal. In comparison the flag &lt;STRONG&gt;IICIF&lt;/STRONG&gt; can be cleared by the user and it must be 0 before sending any byte.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The picture below shows what I mean, by reflecting the values of &lt;STRONG&gt;TCF&lt;/STRONG&gt; and &lt;STRONG&gt;IICIF&lt;/STRONG&gt; in digital pins during a byte transfer; the pulse at the bottom is another pin which is toggled just after the write to &lt;STRONG&gt;I2Cx_D&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper" image-alt="pastedImage_7.png"&gt;&lt;IMG alt="pastedImage_7.png" src="https://community.nxp.com/t5/image/serverpage/image-id/23244i7C3772E0A66E3B68/image-size/large?v=v2&amp;amp;px=999" title="pastedImage_7.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The next code might work when polling &lt;STRONG&gt;TCF&lt;/STRONG&gt;, but you will notice that it is redundant (waiting while &lt;STRONG&gt;TCF = 1&lt;/STRONG&gt; then waiting while &lt;STRONG&gt;TCF = 0&lt;/STRONG&gt;&lt;SPAN class="lia-unicode-emoji" title=":disappointed_face:"&gt;&lt;LI-EMOJI id="lia_disappointed-face" title=":disappointed_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="_jivemacro_uid_14581736243193674 jive_macro_code jive_text_macro" data-renderedposition="815_8_1155_240" jivemacro_uid="_14581736243193674" modifiedtitle="true"&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_SendStart(I2C0_BASE_PTR);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_WriteByte(I2C0_BASE_PTR, 0xA0);&lt;/P&gt;&lt;P&gt;&amp;nbsp; while((I2C0_S &amp;amp; I2C_S_TCF_MASK) == I2C_S_TCF_MASK){}&lt;/P&gt;&lt;P&gt;&amp;nbsp; while((I2C0_S &amp;amp; I2C_S_TCF_MASK) == 0){}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_WriteByte(I2C0_BASE_PTR, 0xB0);&lt;/P&gt;&lt;P&gt;&amp;nbsp; while((I2C0_S &amp;amp; I2C_S_TCF_MASK) == I2C_S_TCF_MASK){}&lt;/P&gt;&lt;P&gt;&amp;nbsp; while((I2C0_S &amp;amp; I2C_S_TCF_MASK) == 0){}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_WriteByte(I2C0_BASE_PTR, 0xC0);&lt;/P&gt;&lt;P&gt;&amp;nbsp; while((I2C0_S &amp;amp; I2C_S_TCF_MASK) == I2C_S_TCF_MASK){}&lt;/P&gt;&lt;P&gt;&amp;nbsp; while((I2C0_S &amp;amp; I2C_S_TCF_MASK) == 0){}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_SendStop(I2C0_BASE_PTR);&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps to clarify.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;Jorge Gonzalez&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Nov 2020 13:25:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/kl25-I2C-HAL-WriteByte/m-p/476385#M29013</guid>
      <dc:creator>Jorge_Gonzalez</dc:creator>
      <dc:date>2020-11-02T13:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: kl25 I2C_HAL_WriteByte()</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/kl25-I2C-HAL-WriteByte/m-p/476386#M29014</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, Jorge.&lt;/P&gt;&lt;P&gt;thank you very much for your replay.&lt;/P&gt;&lt;P&gt;I have done the exactly same test as you do and realized that. I am trying to use more the hall and drive function present at the KSDK. But for many reasons i like to make my own rotines and for that i read the reference manual.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It would save a lot of time if there was a better documentations regarding this. If you read the manual and intend to make a pooling rotine TC would be the choice but does not work as documented.&lt;/P&gt;&lt;P&gt;here is the rotine i made to read the MMA8451. hope this help people with the same problem&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="_jivemacro_uid_14581748091115131 jive_macro_code jive_text_macro" data-renderedposition="242_8_1162_528" jivemacro_uid="_14581748091115131"&gt;&lt;P&gt;unsigned char Read_MMA8451Q_I2C(unsigned char address,unsigned char *buffer,unsigned char qtd)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; unsigned char cnt_i2c;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; while((I2C0_S &amp;amp; I2C_S_TCF_MASK )==0){}&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_SetDirMode(I2C0,1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_SendStart(I2C0);&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_S |= I2C_S_IICIF_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_WriteByte(I2C0,I2C_MMA8451Q_ADD | I2C_WR);&lt;/P&gt;&lt;P&gt;&amp;nbsp; while((I2C0_S &amp;amp; I2C_S_IICIF_MASK)==0){}&lt;/P&gt;&lt;P&gt;&amp;nbsp; if ((I2C0_S &amp;amp; I2C_S_RXAK_MASK) != 0) return(0);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_S |= I2C_S_IICIF_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_WriteByte(I2C0,(address));&lt;/P&gt;&lt;P&gt;&amp;nbsp; while((I2C0_S &amp;amp; I2C_S_IICIF_MASK)==0){}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_SendStart(I2C0);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_S |= I2C_S_IICIF_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_WriteByte(I2C0,I2C_MMA8451Q_ADD | I2C_RD);&lt;/P&gt;&lt;P&gt;&amp;nbsp; while((I2C0_S &amp;amp; I2C_S_IICIF_MASK)==0){}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_SetDirMode(I2C0,0);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_SendAck(I2C0);&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_S |= I2C_S_IICIF_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; (void)I2C_HAL_ReadByte(I2C0);&lt;/P&gt;&lt;P&gt;&amp;nbsp; while((I2C0_S &amp;amp; I2C_S_IICIF_MASK)==0){}&lt;/P&gt;&lt;P&gt;&amp;nbsp; for (cnt_i2c=0 ; cnt_i2c != qtd; ++ cnt_i2c)&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; while((I2C0_S &amp;amp; I2C_S_IICIF_MASK)==0){}&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_S |= I2C_S_IICIF_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; buffer[cnt_i2c] = I2C_HAL_ReadByte(I2C0);&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_SendNak(I2C0);&lt;/P&gt;&lt;P&gt;&amp;nbsp; while((I2C0_S &amp;amp; I2C_S_IICIF_MASK)==0){}&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C_HAL_SendStop(I2C0);&lt;/P&gt;&lt;P&gt;&amp;nbsp; return(1);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Mar 2016 00:38:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/kl25-I2C-HAL-WriteByte/m-p/476386#M29014</guid>
      <dc:creator>Edrianocarlos</dc:creator>
      <dc:date>2016-03-17T00:38:28Z</dc:date>
    </item>
  </channel>
</rss>

