<?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: interrupt i2c in MQX Software Solutions</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/interrupt-i2c/m-p/184477#M3054</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if you have some very specific scenario, you don't have to use I2C driver, just set up pins&amp;nbsp;using _bsp_i2c_io_init(), install your own I2C ISR and enable I2C module and interrupts (see interrupt I2C init function).&lt;/P&gt;&lt;P&gt;If you want to use interrupt I2C driver, you can't get after-interrupt notification, the only way to wait for I2C interrupt is through read or write + fflush (interrrupts are handled within I2C driver):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// example for master mode&lt;/P&gt;&lt;P&gt;fd = fopen ("ii2c0:", NULL);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// read&lt;/P&gt;&lt;P&gt;result = 0;&lt;/P&gt;&lt;P&gt;do&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; result += fread (buffer, 1, 1, fd);&lt;BR /&gt;} while (result &amp;lt; 1);&lt;BR /&gt;your_action();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// write&lt;/P&gt;&lt;P&gt;result = 0;&lt;/P&gt;&lt;P&gt;do&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; result += fwrite (buffer, 1, 1, fd);&lt;BR /&gt;} while (result &amp;lt; 1);&lt;BR /&gt;result = fflush (fd);&lt;/P&gt;&lt;P&gt;your_action();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PetrM&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 14 Dec 2011 20:29:32 GMT</pubDate>
    <dc:creator>PetrM</dc:creator>
    <dc:date>2011-12-14T20:29:32Z</dc:date>
    <item>
      <title>interrupt i2c</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/interrupt-i2c/m-p/184476#M3053</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi I would like learn use MQX.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't understand one thing. When I have for example interrupt (read from I2C) and I would like do something exactly after receive data. How I do it? Because all project what I saw. There was command&amp;nbsp;read_I2C( . and nothing interrution. Please can somebody explain &amp;nbsp;how it works?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 20 Nov 2011 20:18:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/interrupt-i2c/m-p/184476#M3053</guid>
      <dc:creator>Seitec</dc:creator>
      <dc:date>2011-11-20T20:18:13Z</dc:date>
    </item>
    <item>
      <title>Re: interrupt i2c</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/interrupt-i2c/m-p/184477#M3054</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if you have some very specific scenario, you don't have to use I2C driver, just set up pins&amp;nbsp;using _bsp_i2c_io_init(), install your own I2C ISR and enable I2C module and interrupts (see interrupt I2C init function).&lt;/P&gt;&lt;P&gt;If you want to use interrupt I2C driver, you can't get after-interrupt notification, the only way to wait for I2C interrupt is through read or write + fflush (interrrupts are handled within I2C driver):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// example for master mode&lt;/P&gt;&lt;P&gt;fd = fopen ("ii2c0:", NULL);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// read&lt;/P&gt;&lt;P&gt;result = 0;&lt;/P&gt;&lt;P&gt;do&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; result += fread (buffer, 1, 1, fd);&lt;BR /&gt;} while (result &amp;lt; 1);&lt;BR /&gt;your_action();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// write&lt;/P&gt;&lt;P&gt;result = 0;&lt;/P&gt;&lt;P&gt;do&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; result += fwrite (buffer, 1, 1, fd);&lt;BR /&gt;} while (result &amp;lt; 1);&lt;BR /&gt;result = fflush (fd);&lt;/P&gt;&lt;P&gt;your_action();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PetrM&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Dec 2011 20:29:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/interrupt-i2c/m-p/184477#M3054</guid>
      <dc:creator>PetrM</dc:creator>
      <dc:date>2011-12-14T20:29:32Z</dc:date>
    </item>
    <item>
      <title>Re: interrupt i2c</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/interrupt-i2c/m-p/184478#M3055</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thank you very much for explanation&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 25 Dec 2011 18:56:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/interrupt-i2c/m-p/184478#M3055</guid>
      <dc:creator>Seitec</dc:creator>
      <dc:date>2011-12-25T18:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: interrupt i2c</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/interrupt-i2c/m-p/184479#M3056</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi PetrM,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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; I also have a doubt with regards to interrupt&amp;nbsp; mode.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I try to a read in task code, will the &lt;STRONG&gt;task&lt;/STRONG&gt; be &lt;STRONG&gt;blocked&lt;/STRONG&gt; till any new data is read or will it be &lt;STRONG&gt;active&lt;/STRONG&gt; ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my_read_task() {&lt;/P&gt;&lt;P&gt;// read&lt;/P&gt;&lt;P&gt;result = 0;&lt;/P&gt;&lt;P&gt;do&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; result += fread (buffer, 1, 1, fd);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // &lt;STRONG&gt;Will this put the task in blocked state if there is no data ?&lt;/STRONG&gt;&lt;BR /&gt;} while (result &amp;lt; 1);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also the same thing while writing. Will the &lt;STRONG&gt;task&lt;/STRONG&gt; be &lt;STRONG&gt;blocked&lt;/STRONG&gt; till the whole data is transmitted or will it be in &lt;STRONG&gt;active&lt;/STRONG&gt; state ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my_write_task() {&lt;/P&gt;&lt;P&gt;// write&lt;/P&gt;&lt;P&gt;result = 0;&lt;/P&gt;&lt;P&gt;do&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; result += fwrite (buffer, 1, 1, fd);&lt;BR /&gt;} while (result &amp;lt; 1);&lt;BR /&gt;result = fflush (fd); &amp;nbsp; &amp;nbsp; // &lt;STRONG&gt;Will this put the task in blocked state while the data is being written ?&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Mohsin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 01 Jan 2012 20:52:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/interrupt-i2c/m-p/184479#M3056</guid>
      <dc:creator>Mohsin455</dc:creator>
      <dc:date>2012-01-01T20:52:46Z</dc:date>
    </item>
    <item>
      <title>Re: interrupt i2c</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/interrupt-i2c/m-p/184480#M3057</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the interrupt I2C was designed non-blocking. The intention was to transfer the control upon the task to the user so he can decide what to do while I2C transmission is in progress (to block with delay&amp;nbsp;or do some other computation).&lt;/P&gt;&lt;P&gt;So the task remains active all the time.&lt;/P&gt;&lt;P&gt;Regarding the fflush(), it is also done actively using polling because of poor HW design (lack of interrupt requests to important bus events).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;PetrM&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Jan 2012 20:10:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/interrupt-i2c/m-p/184480#M3057</guid>
      <dc:creator>PetrM</dc:creator>
      <dc:date>2012-01-02T20:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: interrupt i2c</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/interrupt-i2c/m-p/184481#M3058</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi PetrM,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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; Thanks for your reply. The wory I have is that the interrupt mode in the present state will consume more CPU time as mentioned in the following post.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A __default_attr="101676" class="jive_macro jive_macro_thread default_title" href="https://community.freescale.com/thread/101676" jivemacro="thread" title="https://community.freescale.com/thread/101676"&gt;https://community.freescale.com/thread/101676&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you let me know your thoughts on enhancing the I2C driver similar to the above post for kinetis TWRK60N512 ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does the same&amp;nbsp; applies to Serial (UART) drivers ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mohsin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Jan 2012 06:48:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/interrupt-i2c/m-p/184481#M3058</guid>
      <dc:creator>Mohsin455</dc:creator>
      <dc:date>2012-01-03T06:48:01Z</dc:date>
    </item>
    <item>
      <title>Re: interrupt i2c</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/interrupt-i2c/m-p/184482#M3059</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had exactly the same problem on a MCF52259. I wanted to have a full interrupt driven I2C driver making my read or write or ioctl calls sleep while tranfer is in progress.&lt;/P&gt;&lt;P&gt;I also wanted to have timeouts to prevent I2C deadlocks.&lt;/P&gt;&lt;P&gt;I did it but only for master mode (did not have the time to do more).&lt;/P&gt;&lt;P&gt;I posted the &lt;A __default_attr="101676" class="jive_macro jive_macro_thread default_title" href="https://community.freescale.com/thread/101676" jivemacro="thread" title="modified code in this post"&gt;modified code in this post&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For an interrupt driven serial line, the read() call sleeps, that's why we do not face the problem of a shell task at higher priority waiting a command while consuming all CPU.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Jan 2012 22:16:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/interrupt-i2c/m-p/184482#M3059</guid>
      <dc:creator>trailman</dc:creator>
      <dc:date>2012-01-14T22:16:21Z</dc:date>
    </item>
  </channel>
</rss>

