<?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>Kinetis MicrocontrollersのトピックRe: Multiple I2C reads with no restart</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Multiple-I2C-reads-with-no-restart/m-p/348808#M17059</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Kas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There shouldn't be anything that is timing specific and I also believe that the ordering of setting TXACK and clearing MST is clear in the flow diagram - (TXACK/MST first then read the rx data byte).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have used the I2C quite intensively in the Coldfires and Kinetis (they are about the same) for 8 years or so and never used any delays. It may be that you have missed clearing the status flag (I2C0_S |= I2C_S_IICIF_MASK) between starting&amp;nbsp; the last data byte read and then sending the stop condition and so the delay is compensating for the fact that the final wait (while ((I2C0_S &amp;amp; I2C_S_IICIF_MASK) == 0){}) is not working since the flag wasn't cleared.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Otherwise I think that the code I use (uinterrupt driven) follows the recommendation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are two details that are possibly missed in the present documentation which trips people up (in standard master mode):&lt;/P&gt;&lt;P&gt;1. The fact that the bus can lock up when the processor is reset during a slave ACK&lt;/P&gt;&lt;P&gt;2. The fact that one needs to be careful about starting a new transmission when the stop bit of a previous transmission hasn't completed&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are a number of discussions about these in the forum:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.nxp.com/message/390098"&gt;Re: How can you detect hang / recover on Kinetis i2c?&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.nxp.com/message/398627#398627" title="https://community.freescale.com/message/398627#398627"&gt;https://community.freescale.com/message/398627#398627&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.nxp.com/message/431418"&gt;Re: Why is there a pause() in I2C routines?&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 14 Dec 2014 17:03:08 GMT</pubDate>
    <dc:creator>mjbcswitzerland</dc:creator>
    <dc:date>2014-12-14T17:03:08Z</dc:date>
    <item>
      <title>Multiple I2C reads with no restart</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Multiple-I2C-reads-with-no-restart/m-p/348805#M17056</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;With help from the Freescale team I was able to get a single register read working perfectly, my code is below. I was wondering what would need to be changed/added to make it a multiregister read. Think of the MPL3115A pressure registers, looking to read 3 or 4 registers without needing to start a new read cycle for each register. I have been able to get two registers but no stop bit at the end. and help would be much appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry for the lack of formatting, but when I try use the C code insert it messes up the code completely &lt;/P&gt;&lt;P&gt;/***********************SINGLE REGISTER READ*****/&lt;/P&gt;&lt;P&gt;int main(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; long int delay;&lt;/P&gt;&lt;P&gt;&amp;nbsp; unsigned char i;&lt;/P&gt;&lt;P&gt;&amp;nbsp; unsigned char result;&lt;/P&gt;&lt;P&gt;&amp;nbsp; char string[] = "My name is Bob C. Marley \r\n\r\n\0";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Clk_Init();&lt;/P&gt;&lt;P&gt;&amp;nbsp; UART_Init();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; SIM_SCGC |= SIM_SCGC_I2C_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; SIM_PINSEL |= SIM_PINSEL_I2C0PS_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_F = 0x11;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_C1 |= I2C_C1_MST_MASK | I2C_C1_TX_MASK | I2C_C1_IICEN_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/**/ //Start&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_C1 |= I2C_C1_MST_MASK | I2C_C1_TX_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/**/ //Write device to read from&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_D = 0x96;//0xC0;&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; //Wait for data to transmit&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_S |= I2C_S_IICIF_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/**/ //Write register to read from&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_D = 0x0B;//0x0C;&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; //Wait for data to transmit&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_S |= I2C_S_IICIF_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/**/ //Restart&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_C1 |= I2C_C1_RSTA_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/**/ //Read from device&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_D = 0x97;//0xC1;&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; //Wait for data to transmit&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_S |= I2C_S_IICIF_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/**/ //RX mode&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I2C0_C1 &amp;amp;= ~I2C_C1_TX_MASK; &lt;/P&gt;&lt;P&gt;/**/ //Turn off its ACK&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I2C0_C1 |= I2C_C1_TXAK_MASK;&lt;/P&gt;&lt;P&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp; for (i = 0; i &amp;lt; 5000; i++){}&lt;/P&gt;&lt;P&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; result = I2C0_D;&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; //Wait for data to transmit&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_S |= I2C_S_IICIF_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_C1 &amp;amp;= ~I2C_C1_MST_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; result = I2C0_D;&lt;/P&gt;&lt;P&gt;&amp;nbsp; for(i = 0; i &amp;lt; 40; i++){&lt;/P&gt;&lt;P&gt;&amp;nbsp; asm("nop");&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/********Multiple Register Read with no stop bit*************************/&lt;/P&gt;&lt;P&gt;int main(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; long int delay;&lt;/P&gt;&lt;P&gt;&amp;nbsp; unsigned char i;&lt;/P&gt;&lt;P&gt;&amp;nbsp; unsigned char result;&lt;/P&gt;&lt;P&gt;&amp;nbsp; char string[] = "My name is Bob C. Marley \r\n\r\n\0";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Clk_Init();&lt;/P&gt;&lt;P&gt;&amp;nbsp; UART_Init();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; SIM_SCGC |= SIM_SCGC_I2C_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; SIM_PINSEL |= SIM_PINSEL_I2C0PS_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_F = 0x11;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_C1 |= I2C_C1_MST_MASK | I2C_C1_TX_MASK | I2C_C1_IICEN_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/**/ //Start&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_C1 |= I2C_C1_MST_MASK | I2C_C1_TX_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/**/ //Write device to read from&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_D = 0x96;//0xC0;&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; //Wait for data to transmit&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_S |= I2C_S_IICIF_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/**/ //Write register to read from&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_D = 0x01;//0x0C;&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; //Wait for data to transmit&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_S |= I2C_S_IICIF_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/**/ //Restart&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_C1 |= I2C_C1_RSTA_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/**/ //Read from device&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_D = 0x97;//0xC1;&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; //Wait for data to transmit&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_S |= I2C_S_IICIF_MASK;&lt;/P&gt;&lt;P&gt;/**/ //RX mode&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I2C0_C1 &amp;amp;= ~I2C_C1_TX_MASK; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I2C0_C1 &amp;amp;= ~I2C_C1_TXAK_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; result = I2C0_D;&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; //Wait for data to transmit&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;/**/ //Turn off its ACK&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_C1 |= I2C_C1_TXAK_MASK;I2C0_C1 |= I2C_C1_TXAK_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; result = I2C0_D;&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; //Wait for data to transmit&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_S |= I2C_S_IICIF_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_C1 &amp;amp;= ~I2C_C1_MST_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; result = I2C0_D;&lt;/P&gt;&lt;P&gt;&amp;nbsp; for(i = 0; i &amp;lt; 40; i++){&lt;/P&gt;&lt;P&gt;&amp;nbsp; asm("nop");&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; return 0;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Dec 2014 19:22:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Multiple-I2C-reads-with-no-restart/m-p/348805#M17056</guid>
      <dc:creator>kaslewis</dc:creator>
      <dc:date>2014-12-12T19:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple I2C reads with no restart</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Multiple-I2C-reads-with-no-restart/m-p/348806#M17057</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Kas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The user's manual show you how to do this. Just copy the flow chart that it gives:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_0.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/48238iE606462E0FD0730D/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_0.png" alt="pastedImage_0.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since you are not using interrupts just spin waiting for the IICIF - then enter the flow diagram and either loop back to waiting on the flag, or quit when all is done.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Generally however consider using interrupts so that the processor can do other things in parallel (unless doing this in a low priority task under a pre-emptive operating system).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Dec 2014 22:53:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Multiple-I2C-reads-with-no-restart/m-p/348806#M17057</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2014-12-12T22:53:47Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple I2C reads with no restart</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Multiple-I2C-reads-with-no-restart/m-p/348807#M17058</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank You Mark, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But again as with my first issue here stating the obvious does not help. The above flow diagram is pretty much useless as accurate order and timing are missing. Example of such iris when is the TXACK set, before or after receiving the second to last byte same with the MST = 0. Also there is no mention of timing. After all is said and done all I was missing was a time delay after receiving the final bit before setting MST = 0, there is NO mention of this anywhere in the chapter on I2C. Anyways all said and done I have it working now but this is one BIG issue I have with Freescale is their appalling documentation due to its ambiguity.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just to be sure Mark, this rant is not against you as in fact your comment made me think of how many ways can a chart be interpreted and one of those was the answer, but rather against Freescale and their terrible documentation and costumer service.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Dec 2014 07:02:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Multiple-I2C-reads-with-no-restart/m-p/348807#M17058</guid>
      <dc:creator>kaslewis</dc:creator>
      <dc:date>2014-12-14T07:02:00Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple I2C reads with no restart</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Multiple-I2C-reads-with-no-restart/m-p/348808#M17059</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Kas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There shouldn't be anything that is timing specific and I also believe that the ordering of setting TXACK and clearing MST is clear in the flow diagram - (TXACK/MST first then read the rx data byte).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have used the I2C quite intensively in the Coldfires and Kinetis (they are about the same) for 8 years or so and never used any delays. It may be that you have missed clearing the status flag (I2C0_S |= I2C_S_IICIF_MASK) between starting&amp;nbsp; the last data byte read and then sending the stop condition and so the delay is compensating for the fact that the final wait (while ((I2C0_S &amp;amp; I2C_S_IICIF_MASK) == 0){}) is not working since the flag wasn't cleared.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Otherwise I think that the code I use (uinterrupt driven) follows the recommendation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are two details that are possibly missed in the present documentation which trips people up (in standard master mode):&lt;/P&gt;&lt;P&gt;1. The fact that the bus can lock up when the processor is reset during a slave ACK&lt;/P&gt;&lt;P&gt;2. The fact that one needs to be careful about starting a new transmission when the stop bit of a previous transmission hasn't completed&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are a number of discussions about these in the forum:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.nxp.com/message/390098"&gt;Re: How can you detect hang / recover on Kinetis i2c?&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.nxp.com/message/398627#398627" title="https://community.freescale.com/message/398627#398627"&gt;https://community.freescale.com/message/398627#398627&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.nxp.com/message/431418"&gt;Re: Why is there a pause() in I2C routines?&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 14 Dec 2014 17:03:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Multiple-I2C-reads-with-no-restart/m-p/348808#M17059</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2014-12-14T17:03:08Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple I2C reads with no restart</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Multiple-I2C-reads-with-no-restart/m-p/348809#M17060</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for the info Mark,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have attached my code so you can see what I am referring too as well as for others who may look here for a full answer. The delay I am referring to is on line 218 and as far as i can tell that was the only real change I made from what I had and what I got from someone in Freescale.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cant seem to attach a file so I'll just add it here :smileysad:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*&lt;/P&gt;&lt;P&gt; * main implementation: use this 'C' sample to create your own application&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;&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;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#include "derivative.h" /* include peripheral declarations */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#define MWSR&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x00&amp;nbsp; /* Master write&amp;nbsp; */&lt;/P&gt;&lt;P&gt;#define MRSW&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x01&amp;nbsp; /* Master read */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#define i2c_Start()&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I2C0_C1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |= 0x10;\&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I2C0_C1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |= I2C_C1_MST_MASK&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#define i2c_write_byte(data)&amp;nbsp;&amp;nbsp; I2C0_D = data&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#define i2c_Wait()&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while((I2C0_S &amp;amp; I2C_S_IICIF_MASK)==0) {} \&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I2C0_S |= I2C_S_IICIF_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#define i2c_Stop()&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I2C0_C1&amp;nbsp; &amp;amp;= ~I2C_C1_MST_MASK;\&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I2C0_C1&amp;nbsp; &amp;amp;= ~I2C_C1_TX_MASK&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;unsigned char MasterTransmission;&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; * Pause Routine&lt;/P&gt;&lt;P&gt; */&lt;/P&gt;&lt;P&gt;void Pause(void){&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int n;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(n=1;n&amp;lt;50;n++) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; asm("nop");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&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;*&lt;/P&gt;&lt;P&gt;* @brief&amp;nbsp;&amp;nbsp;&amp;nbsp; Uart_SendChar - Send a single byte on Uart1 &lt;/P&gt;&lt;P&gt;* @param&amp;nbsp;&amp;nbsp;&amp;nbsp; byte to send&lt;/P&gt;&lt;P&gt;* @return&amp;nbsp;&amp;nbsp; none&lt;/P&gt;&lt;P&gt;*&lt;/P&gt;&lt;P&gt;************************************************************************************************/&amp;nbsp; &lt;/P&gt;&lt;P&gt;void Uart_SendChar(uint8_t send)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; while((UART2_S1&amp;amp;UART_S1_TDRE_MASK)==0);&lt;/P&gt;&lt;P&gt;&amp;nbsp; (void)UART2_S1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; UART2_D=send;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;unsigned char readRegister(unsigned char slaveID, unsigned char registerAddress)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; unsigned char result;&lt;/P&gt;&lt;P&gt;&amp;nbsp; unsigned int j;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; MasterTransmission = MRSW;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; slaveID = slaveID &amp;lt;&amp;lt; 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; slaveID |= MasterTransmission; &lt;/P&gt;&lt;P&gt;&amp;nbsp; i2c_Start();&lt;/P&gt;&lt;P&gt;&amp;nbsp; i2c_write_byte(slaveID);&lt;/P&gt;&lt;P&gt;&amp;nbsp; i2c_Wait();&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_D = registerAddress;&lt;/P&gt;&lt;P&gt;&amp;nbsp; i2c_Wait();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* Do a repeated start */&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_C1 |= I2C_C1_RSTA_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* Send Slave Address */&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_D = (slaveID &amp;lt;&amp;lt; 1) | 0x01; //read address&lt;/P&gt;&lt;P&gt;&amp;nbsp; i2c_Wait();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* Put in Rx Mode */&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_C1 &amp;amp;= (~I2C_C1_TX_MASK);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* Turn off ACK */&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_C1 |= I2C_C1_TXAK_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* Dummy read */&lt;/P&gt;&lt;P&gt;&amp;nbsp; result = I2C0_D ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; for (j=0; j&amp;lt;5000; j++){};&lt;/P&gt;&lt;P&gt;&amp;nbsp; i2c_Wait();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /* Send stop */&lt;/P&gt;&lt;P&gt;&amp;nbsp; i2c_Stop();&lt;/P&gt;&lt;P&gt;&amp;nbsp; result = I2C0_D ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Pause();&lt;/P&gt;&lt;P&gt;&amp;nbsp; return result;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void writeRegister(unsigned char slaveID, unsigned char registerAddress, unsigned char data)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; MasterTransmission = MWSR;&lt;/P&gt;&lt;P&gt;&amp;nbsp; slaveID = slaveID &amp;lt;&amp;lt; 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; slaveID |= MasterTransmission; &lt;/P&gt;&lt;P&gt;&amp;nbsp; i2c_Start();&lt;/P&gt;&lt;P&gt;&amp;nbsp; i2c_write_byte(slaveID);&lt;/P&gt;&lt;P&gt;&amp;nbsp; i2c_Wait();&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_D = registerAddress;&lt;/P&gt;&lt;P&gt;&amp;nbsp; i2c_Wait();&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_D = data;&lt;/P&gt;&lt;P&gt;&amp;nbsp; i2c_Wait();&lt;/P&gt;&lt;P&gt;&amp;nbsp; i2c_Stop();&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//void clkInit(){&lt;/P&gt;&lt;P&gt;// //Clock setup&lt;/P&gt;&lt;P&gt;// SIM_BUSDIV = 0; //Divide bus clock by 1&lt;/P&gt;&lt;P&gt;// ICS_C1 |= ICS_C1_IRCLKEN_MASK; //Use internal reference clock &lt;/P&gt;&lt;P&gt;// ICS_C3 = 0x50; //Multiply the internal reference clock by 64, 16 = 39.0625 KHz&lt;/P&gt;&lt;P&gt;// //Wait for clock to lock (running at 40 MHz (1024 * 39.0625Khz)&lt;/P&gt;&lt;P&gt;// while(!(ICS_S &amp;amp; ICS_S_LOCK_MASK ));&lt;/P&gt;&lt;P&gt;// ICS_C2 |= ICS_C2_BDIV(1); //Divide the bus clock by 2&lt;/P&gt;&lt;P&gt;// ICS_S |= ICS_S_LOCK_MASK; //Clear Loss of lock sticky bit&lt;/P&gt;&lt;P&gt;//}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void Clk_Init()&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; ICS_C1|=ICS_C1_IRCLKEN_MASK; /* Enable the internal reference clock*/ &lt;/P&gt;&lt;P&gt;&amp;nbsp; ICS_C3= 0x50; /* Reference clock frequency = 39.0625 KHz*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; while(!(ICS_S &amp;amp; ICS_S_LOCK_MASK));&amp;nbsp;&amp;nbsp; /* Wait for PLL lock, now running at 40 MHz (1024 * 39.0625Khz) */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ICS_C2|=ICS_C2_BDIV(1)&amp;nbsp; ; /*BDIV=2, Bus clock = 20 MHz*/&lt;/P&gt;&lt;P&gt;&amp;nbsp; ICS_S |= ICS_S_LOCK_MASK ; /* Clear Loss of lock sticky bit */&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//void uartInit(){&lt;/P&gt;&lt;P&gt;// //UART setup&lt;/P&gt;&lt;P&gt;// SIM_SCGC |= SIM_SCGC_UART2_MASK;&lt;/P&gt;&lt;P&gt;// UART2_BDH = 0x00;&lt;/P&gt;&lt;P&gt;// UART2_BDL = 128;&lt;/P&gt;&lt;P&gt;// UART2_C1 = 0x00;&lt;/P&gt;&lt;P&gt;// UART2_C2 |= UART_C2_TE_MASK | UART_C2_RE_MASK;// | UART_C2_RIE_MASK | UART_C2_TIE_MASK;&lt;/P&gt;&lt;P&gt;//}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void UART_Init()&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; SIM_SCGC |=&amp;nbsp; SIM_SCGC_UART2_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; UART2_BDL= 128;&lt;/P&gt;&lt;P&gt;&amp;nbsp; UART2_C1 = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; UART2_C2 |= UART_C2_TE_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; UART2_C2 |= UART_C2_RE_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; UART2_C2 |= UART_C2_RIE_MASK;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//void i2cInit(){&lt;/P&gt;&lt;P&gt;// //I2C setup&lt;/P&gt;&lt;P&gt;// SIM_SCGC |= SIM_SCGC_I2C_MASK;&lt;/P&gt;&lt;P&gt;// SIM_PINSEL |= SIM_PINSEL_I2C0PS_MASK;&lt;/P&gt;&lt;P&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp; I2C0_F = 0x00;&lt;/P&gt;&lt;P&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp; I2C0_C1 = I2C_C1_IICEN_MASK | I2C_C1_MST_MASK | I2C_C1_IICIE_MASK; &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;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;int main(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; long int delay;&lt;/P&gt;&lt;P&gt;&amp;nbsp; unsigned char i;&lt;/P&gt;&lt;P&gt;&amp;nbsp; unsigned char result;&lt;/P&gt;&lt;P&gt;&amp;nbsp; char string[] = "My name is Bob C. Marley \r\n\r\n\0";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Clk_Init();&lt;/P&gt;&lt;P&gt;&amp;nbsp; UART_Init();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; SIM_SCGC |= SIM_SCGC_I2C_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; SIM_PINSEL |= SIM_PINSEL_I2C0PS_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_F = 0x11;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_C1 |= I2C_C1_MST_MASK | I2C_C1_TX_MASK | I2C_C1_IICEN_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; while(1){&lt;/P&gt;&lt;P&gt;&amp;nbsp; /**/ //Start&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_C1 |= I2C_C1_MST_MASK | I2C_C1_TX_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_C1 &amp;amp;= ~I2C_C1_TXAK_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /**/ //Write device to read from&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_D = 0x96;&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; //Wait for data to transmit&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_S |= I2C_S_IICIF_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /**/ //Write register to read from&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_D = 0x00;&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; //Wait for data to transmit&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_S |= I2C_S_IICIF_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /**/ //Restart&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_C1 |= I2C_C1_RSTA_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /********************************************************Read*************/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /**/ //Read from device&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_D = 0x97;&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; //Wait for data to transmit&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_S |= I2C_S_IICIF_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /**/ //RX mode&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_C1 &amp;amp;= ~I2C_C1_TX_MASK; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /**/ //Turn off its ACK&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; result = I2C0_D;&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; //Wait for data to transmit&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_C1 |= I2C_C1_TXAK_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; result = I2C0_D;&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; //Wait for data to transmit&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; for(i = 0; i &amp;lt; 40; i++){&lt;/P&gt;&lt;P&gt;&amp;nbsp; asm("nop");&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_S |= I2C_S_IICIF_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I2C0_C1 &amp;amp;= ~I2C_C1_MST_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp; result = I2C0_D;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; // while(1) {&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; //&amp;nbsp;&amp;nbsp; for (i = 0; string[i] != '\0'; i++){&lt;/P&gt;&lt;P&gt;&amp;nbsp; //&amp;nbsp;&amp;nbsp; Uart_SendChar(string[i]);&lt;/P&gt;&lt;P&gt;&amp;nbsp; //&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; //&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; //&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(delay = 0; delay &amp;lt; 99999; delay++);&lt;/P&gt;&lt;P&gt;&amp;nbsp; // }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&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;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// Uart_SetCallback(Uart_Interrupt); /* Set the callback function that the UART driver will call when receiving a char */&lt;/P&gt;&lt;P&gt;// Enable_Interrupt(INT_UART2);&amp;nbsp;&amp;nbsp; /* Enable UART2 interrupt */&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;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; return 0;&lt;/P&gt;&lt;P&gt;} &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Dec 2014 18:07:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Multiple-I2C-reads-with-no-restart/m-p/348809#M17060</guid>
      <dc:creator>kaslewis</dc:creator>
      <dc:date>2014-12-16T18:07:09Z</dc:date>
    </item>
    <item>
      <title>Re: Re: Multiple I2C reads with no restart</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Multiple-I2C-reads-with-no-restart/m-p/348810#M17061</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Kas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To attach files you need to enable the advanced editor (top right corner) and then there is an attach button (at the bottom right corner).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can't follow the code that you posted above. There is some reading code in the main loop but other reading code in readRegister (with the new delay) but it is not being called to see what is happening afterwards (which could be affected the the delay before returning). There are also new functions like i2c_Wait() with no code showing what they do. There were originally&amp;nbsp; also delays with no obvious purpose, such as&lt;/P&gt;&lt;P&gt;&amp;nbsp; for (j=0; j&amp;lt;5000; j++){};&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As noted previously, code with delays and no comments (explaining why they are needed, plus pointing to the detail in the chips data sheet, user's manual or errata) are often not needed and were added "in desparation" by someone who found that it changed things enought to stop an 'unwanted' behaviour. &lt;EM&gt;There are some valid delays that are required (eg. the data sheet may point out that some operation is not possible until a peripheral has completed an internal reset or synchronised to a different bus, which can take a maximum number of clock cycles or us) but not usually in interrupt or flag driven peripheral drivers.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Workarounds of this nature can fail when conditions change, or bus clocks or peripheral speeds are adjusted, or a different device type is moved to and so are potential code-bombs that can go off at some time in future and require a proper solution to be worked out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below I have attached the I2C interrupt code for the reception case from the uTasker project as reference but I don't see any basic difference to the order of operations (most of the code is for the I2C driver's state and rx circular buffer). The transmission of the first byte is not shown because that is not in the interrupt but it is only sending the start condition and the first byte.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_141875604274533" jivemacro_uid="_141875604274533" modifiedtitle="true"&gt;
&lt;P&gt;I2C0_S = IIC_IIF; // clear the interrupt flag&lt;/P&gt;
&lt;P&gt;unsigned char ucFirstRead = (I2C0_C1 &amp;amp; IIC_MTX); &lt;/P&gt;
&lt;P&gt;if (IIC_tx_control[0]-&amp;gt;ucPresentLen == 1) { // final byte&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I2C0_C1 = (IIC_IEN | IIC_IIEN | IIC_MSTA | IIC_TXAK); // we don't acknowledge last byte&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;else if (IIC_tx_control[0]-&amp;gt;ucPresentLen == 0) { // we have completed the read&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I2C0_C1 = (IIC_IEN | IIC_TXAK); // send end condition and disable interrupts&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IIC_tx_control[0]-&amp;gt;ucState &amp;amp;= ~(TX_WAIT | TX_ACTIVE | RX_ACTIVE);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IIC_rx_control[0]-&amp;gt;msgs++;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (IIC_rx_control[0]-&amp;gt;wake_task != 0) { // wake up the receiver task if desired&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uTaskerStateChange(IIC_rx_control[0]-&amp;gt;wake_task, UTASKER_ACTIVATE); // wake up owner task&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;else {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I2C0_C1 = (IIC_IEN | IIC_IIEN | IIC_MSTA); // ensure we acknowledge multibyte reads&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;if (ucFirstRead != 0) { // have we just sent the slave address?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (void)I2C0_D; // dummy read&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;else {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; *IIC_rx_control[0]-&amp;gt;IIC_queue.put++ = I2C0_D; // read the byte&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IIC_rx_control[0]-&amp;gt;IIC_queue.chars++; // and put it into the rx buffer&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (IIC_rx_control[0]-&amp;gt;IIC_queue.put &amp;gt;= IIC_rx_control[0]-&amp;gt;IIC_queue.buffer_end) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IIC_rx_control[0]-&amp;gt;IIC_queue.put = IIC_rx_control[0]-&amp;gt;IIC_queue.QUEbuffer;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;if (IIC_tx_control[0]-&amp;gt;ucPresentLen != 0) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IIC_tx_control[0]-&amp;gt;ucPresentLen--;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;else { // read sequence complete so continue with next write if something is waiting&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (IIC_tx_control[0]-&amp;gt;IIC_queue.chars != 0) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fnTxIIC(IIC_tx_control[0], 0); // we have another message to send so we can send a repeated start condition&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Dec 2014 18:56:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Multiple-I2C-reads-with-no-restart/m-p/348810#M17061</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2014-12-16T18:56:36Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple I2C reads with no restart</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Multiple-I2C-reads-with-no-restart/m-p/348811#M17062</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Such code as this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"#define i2c_Stop() I2C0_C1 &amp;amp;= ~I2C_C1_MST_MASK;\&lt;BR /&gt;I2C0_C1 &amp;amp;= ~I2C_C1_TX_MASK;"&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;needs to be put in do{}while(0) like this:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;"#define i2c_Stop() do{ I2C0_C1 &amp;amp;= ~I2C_C1_MST_MASK; I2C0_C1 &amp;amp;= ~I2C_C1_TX_MASK; }while(0).&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;This prevents a bug should i2c_Stop() et.al. be used after a if() statement that is not using {}.&amp;nbsp; Always a good idea to use the {} even if not required.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Some compilers with aggressive optimizers will remove code like this:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;while(!(ICS_S &amp;amp; ICS_S_LOCK_MASK)); &lt;/P&gt;&lt;P&gt;&lt;BR /&gt;because it has no side effects.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Placing a volatile nop instruction in {} will prevent the code from being optimized away.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;static inline void nop( void ) /* For GCC */&lt;BR /&gt;{&lt;BR /&gt; __asm__ __volatile__ ("nop");&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;while(!(ICS_S &amp;amp; ICS_S_LOCK_MASK))&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; nop();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;That is why it appears that adding delays fix things.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Dec 2014 14:10:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Multiple-I2C-reads-with-no-restart/m-p/348811#M17062</guid>
      <dc:creator>bobpaddock</dc:creator>
      <dc:date>2014-12-22T14:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple I2C reads with no restart</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Multiple-I2C-reads-with-no-restart/m-p/348812#M17063</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mark,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was able to remove all delays from my code with a bit of work thank you for pushing me to do that :smileyhappy:, I had everything working but I now have some odd happenings as I have outlined in a &lt;A _jive_internal="true" href="https://community.nxp.com/message/465606#465606"&gt;new question thread&lt;/A&gt;. I have also posted a full copy of my code there (with comments) if anyone wants to have a look how I finally got my code to mostly work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Kas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Dec 2014 17:47:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Multiple-I2C-reads-with-no-restart/m-p/348812#M17063</guid>
      <dc:creator>kaslewis</dc:creator>
      <dc:date>2014-12-26T17:47:59Z</dc:date>
    </item>
  </channel>
</rss>

