<?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: MKL26Z256 - Can DMA UART RX end transfer on RX idle? in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911886#M53473</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That is unexpected.&lt;/P&gt;&lt;P&gt;I had a problem were the DMA BCR would change, but the DMA buffer had zeros at the end of the buffer instead of my data. I did not see the new data at the start of the buffer.&lt;/P&gt;&lt;P&gt;Maybe the BCR wrapped, and now my data was written to an address below the original DAR.&lt;/P&gt;&lt;P&gt;That might explain why my hardware appeared to stop working properly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't know of a way to allocate a buffer on module boundary using some magic compiler pragma.&lt;/P&gt;&lt;P&gt;The align macro will not work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe some assembly magic would allow a 1KB buffer to be placed in some RAM location.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe a buffer could be allocated from the heap, before the FreeRTOS scheduler is started, using malloc() and&amp;nbsp;realloc().&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Bruce&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;char * pAddress;&lt;/P&gt;&lt;P&gt;char * pStart = 0;&lt;/P&gt;&lt;P&gt;char * pDMAbyte = 0;&lt;/P&gt;&lt;P&gt;bool bDone = false;&lt;/P&gt;&lt;P&gt;do&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &lt;SPAN&gt;pAddress&amp;nbsp;&lt;/SPAN&gt;= malloc(1);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; if (0 == pStart)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pStart = &lt;SPAN&gt;pAddress&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; if (0 == (&lt;SPAN&gt;pAddress&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;amp; 0xFF))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;SPAN&gt;pDMAbyte&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;= pAddress;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;} while(0 == &lt;SPAN&gt;pDMAbyte&lt;/SPAN&gt;);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;//&amp;nbsp;&lt;SPAN&gt;free the bytes from pStart to &lt;SPAN&gt;pDMAbyte&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;for (char * pFree =&amp;nbsp;&lt;SPAN&gt;pStart; &lt;SPAN&gt;pFree&lt;SPAN&gt;&amp;nbsp;&amp;lt; &lt;SPAN&gt;pDMAbyte&lt;/SPAN&gt;; ++pFree)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; free(pFree);&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;char pDMA;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;pDMA = realloc(pDMAbyte, 1024);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;// realloc() may have freed memory at pDMAbyte and&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;// may allocate a new&amp;nbsp;memory block from some other address other then pDMAbyte.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;// If this works then&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;assert(pDMA ==&amp;nbsp;pDMAbyte);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 21 Aug 2019 18:43:09 GMT</pubDate>
    <dc:creator>bgraham</dc:creator>
    <dc:date>2019-08-21T18:43:09Z</dc:date>
    <item>
      <title>MKL26Z256 - Can DMA UART RX end transfer on RX idle?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911855#M53442</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P class="" style="color: #333333; background-color: #ffffff; border: 0px; margin: 6px 0px 0px;"&gt;MCUXpresso IDE v11.0.0 [Build 2516] [2019-06-05]&lt;/P&gt;&lt;P class="" style="color: #333333; background-color: #ffffff; border: 0px; margin: 6px 0px 0px;"&gt;&lt;SPAN class="" style="border: 0px; font-weight: inherit;"&gt;Device:&lt;/SPAN&gt;&lt;SPAN style="border: 0px; font-weight: inherit;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="" style="border: 0px; font-weight: 600;"&gt;MKL26Z256xxx4&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #333333; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN class="" style="border: 0px; font-weight: inherit;"&gt;&lt;/SPAN&gt;&lt;SPAN class="" style="border: 0px; font-weight: inherit;"&gt;&lt;/SPAN&gt;&lt;SPAN class="" style="border: 0px; font-weight: inherit;"&gt;SDK_2.x_MKL26Z256xxx4&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="" style="border: 0px; font-weight: 600;"&gt;2.4.1&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class="" style="color: #333333; background-color: #ffffff; border: 0px; padding: 4px 0px 0px;"&gt;&lt;P style="border: 0px; font-weight: inherit;"&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;I started with the driver example UART dma_transfer project.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;The project has the DMA RX setup to receive fixed length transfers.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;I am working with a modem, so I can't predict the transfer length of the data from the modem.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;I need a why to end the DMA RX transfer when the UART line is idle.&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;Is it possible to end the DMA transfer when the UART Controller generates an IDLE interrupt?&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;Thanks,&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;Bruce&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Jul 2019 14:05:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911855#M53442</guid>
      <dc:creator>bgraham</dc:creator>
      <dc:date>2019-07-26T14:05:01Z</dc:date>
    </item>
    <item>
      <title>Re: MKL26Z256 - Can DMA UART RX end transfer on RX idle?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911856#M53443</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In fsl_uart.h&amp;nbsp;UART_EnableRxDMA() the UART's C4.&lt;SPAN&gt;RDMAS&lt;/SPAN&gt;&amp;nbsp;is getting set to cause an interrupt when the DMA buffer is full.&lt;/P&gt;&lt;P&gt;I don't want this. Instead, I want the interrupt to occur when the UART peripheral detects an RX IDLE.&lt;/P&gt;&lt;P&gt;In the KL26 manual, I see the&amp;nbsp;&lt;SPAN&gt;UART has a&amp;nbsp;&lt;STRONG&gt;ILDMAS&lt;/STRONG&gt; register.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;See&amp;nbsp;&lt;SPAN&gt;Table 40-34 below.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Would setting&amp;nbsp;the UART's&amp;nbsp;&lt;STRONG&gt;ILDMAS&lt;/STRONG&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;register end the DMA transfer on RX IDLE?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Where is the UART's &lt;STRONG&gt;ILDMAS&lt;/STRONG&gt; register and how do I set it?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Bruce&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;KL26 Sub-Family Reference Manual, Rev. 3.2, October 2013&lt;/P&gt;&lt;P&gt;40.4.6 DMA Operation&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Table 40-34. DMA configuration&lt;/P&gt;&lt;P&gt;====================================&lt;/P&gt;&lt;P&gt;Flag&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Request enable bit&amp;nbsp; &amp;nbsp; DMA select bit&lt;/P&gt;&lt;P&gt;RDRF&amp;nbsp; &amp;nbsp; &amp;nbsp;RIE = 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RDMAS = 1&lt;BR /&gt;IDLE&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ILIE =1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;ILDMAS&lt;/STRONG&gt; = 1&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Jul 2019 15:45:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911856#M53443</guid>
      <dc:creator>bgraham</dc:creator>
      <dc:date>2019-07-26T15:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: MKL26Z256 - Can DMA UART RX end transfer on RX idle?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911857#M53444</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As you know, having DMA reception that needs to know how much data will be received beforehand is only of practical use in very limited situations.&lt;BR /&gt;The more general solution is to have free-running UART DMA to a circular buffer (which all Kinetis parts with DMA allow). You can either poll the buffer (eg. whenever there is nothing else to do, every 1ms or 10ms, etc.) depending on the protocol involved and the reaction time required to a complete message reception, or you can use the idle line interrupt to signal when there 'might' be a message waiting and it is worth taking a look.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When the UART is operating in DMA reception mode it will be triggering a DMA channel and not interrupting to inform of reception. This means that in the reference you refer to it is the DMA controller interrupting to inform that the pre-defined number of transfers has been made and not the UART. The UART can however be configured to interrupt on idle line and this interrupt then used to check the reception state. The idle line condition however has no interaction with the DMA operation and so code in the idle line interrupt needs to do whatever required.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that a further advantage of free-running DMA reception over the pre-defined reception length is that the fixed reception length method requires the DMA to be set up "again" for the next reception. If the data rate is high it may be that the code is not always fast enough to react to the initial end of DMA interrupt and set up before the start of the next message arrives and is lost (overrun). Free running DMA to a large circular buffer (no firmware intervention needed) ensures that no overrun can occur even at very high data rates.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following videos explain free-running Rx UART DMA on a KL27 (which is compatible with KL26):&lt;BR /&gt;&lt;A href="https://www.youtube.com/watch?v=dNZvvouiqis&amp;amp;list=PLWKlVb_MqDQFZAulrUywU30v869JBYi9Q&amp;amp;index=10" target="test_blank"&gt;https://www.youtube.com/watch?v=dNZvvouiqis&amp;amp;list=PLWKlVb_MqDQFZAulrUywU30v869JBYi9Q&amp;amp;index=10&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://www.youtube.com/watch?v=GaoWE-tMRq4&amp;amp;list=PLWKlVb_MqDQFZAulrUywU30v869JBYi9Q&amp;amp;index=11" target="test_blank"&gt;https://www.youtube.com/watch?v=GaoWE-tMRq4&amp;amp;list=PLWKlVb_MqDQFZAulrUywU30v869JBYi9Q&amp;amp;index=11&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is another video [without sound - that I don't remember any more for what reason it was made] showing a simulated KL27 using Rx and Tx DMA and also idle line interrupt for Modbus RTU protocol:&lt;BR /&gt;&lt;A href="https://www.youtube.com/watch?v=OrqSn9x7N1E" target="test_blank"&gt;https://www.youtube.com/watch?v=OrqSn9x7N1E&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&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;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;EM&gt;Complete Kinetis solutions for professional needs, training and support: &lt;A href="http://www.utasker.com/kinetis.html" target="test_blank"&gt;http://www.utasker.com/kinetis.html&lt;/A&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Kinetis KL25, KL26, KL27, KL28, KL43, KL46, KL82&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;- &lt;A href="http://http://www.utasker.com/kinetis/FRDM-KL25Z.html" target="test_blank"&gt;http://http://www.utasker.com/kinetis/FRDM-KL25Z.html&lt;/A&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;- &lt;A href="http://www.utasker.com/kinetis/TWR-KL25Z48M.html" target="test_blank"&gt;http://www.utasker.com/kinetis/TWR-KL25Z48M.html&lt;/A&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;- &lt;A href="http://www.utasker.com/kinetis/FRDM-KL26Z.html" target="test_blank"&gt;http://www.utasker.com/kinetis/FRDM-KL26Z.html&lt;/A&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;- &lt;A href="http://www.utasker.com/kinetis/TEENSY_LC.html" target="test_blank"&gt;http://www.utasker.com/kinetis/TEENSY_LC.html&lt;/A&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;- &lt;A href="http://www.utasker.com/kinetis/FRDM-KL27Z.html" target="test_blank"&gt;http://www.utasker.com/kinetis/FRDM-KL27Z.html&lt;/A&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;- &lt;A href="http://www.utasker.com/kinetis/Capuccino-KL27.html" target="test_blank"&gt;http://www.utasker.com/kinetis/Capuccino-KL27.html&lt;/A&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;- &lt;A href="http://www.utasker.com/kinetis/FRDM-KL28Z.html" target="test_blank"&gt;http://www.utasker.com/kinetis/FRDM-KL28Z.html&lt;/A&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;- &lt;A href="http://www.utasker.com/kinetis/FRDM-KL43Z.html" target="test_blank"&gt;http://www.utasker.com/kinetis/FRDM-KL43Z.html&lt;/A&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;- &lt;A href="http://www.utasker.com/kinetis/TWR-KL43Z48M.html" target="test_blank"&gt;http://www.utasker.com/kinetis/TWR-KL43Z48M.html&lt;/A&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;- &lt;A href="http://www.utasker.com/kinetis/FRDM-KL46Z.html" target="test_blank"&gt;http://www.utasker.com/kinetis/FRDM-KL46Z.html&lt;/A&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;- &lt;A href="http://www.utasker.com/kinetis/TWR-KL46Z48M.html" target="test_blank"&gt;http://www.utasker.com/kinetis/TWR-KL46Z48M.html&lt;/A&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;- &lt;A href="http://www.utasker.com/kinetis/FRDM-KL82Z.html" target="test_blank"&gt;http://www.utasker.com/kinetis/FRDM-KL82Z.html&lt;/A&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="color: #000080;"&gt;&lt;EM&gt;uTasker: supporting &amp;gt;1'000 registered Kinetis users get products faster and cheaper to market&lt;/EM&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;EM&gt;Request Free emergency remote desk-top consulting at &lt;A href="http://www.utasker.com/services.html" target="test_blank"&gt;http://www.utasker.com/services.html&lt;/A&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Open Source version at &lt;A href="https://github.com/uTasker/uTasker-Kinetis" target="test_blank"&gt;https://github.com/uTasker/uTasker-Kinetis&lt;/A&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Jul 2019 20:51:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911857#M53444</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2019-07-26T20:51:13Z</dc:date>
    </item>
    <item>
      <title>Re: MKL26Z256 - Can DMA UART RX end transfer on RX idle?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911858#M53445</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I made it very clear in my comments that I am using FreeRTOS and the Kinetic SDK.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wasted an hour looking for at utasker.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!&lt;/SPAN&gt;I WILL NOT convert my project to utasker!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!&lt;/SPAN&gt;I WILL NOT convert my project to utasker!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!&lt;/SPAN&gt;I WILL NOT convert my project to utasker!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The utasker suggestion is worthless to me,&amp;nbsp;&lt;/SPAN&gt;so please no more utasker.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The&amp;nbsp;free-running Rx UART DMA sounds great.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After going through the&amp;nbsp;KL26 Sub-Family Reference Manual, Rev. 3.2, October 2013, and the&amp;nbsp;Kinetis SDK v.2.0 API Reference Manual, I don't have clear idea how to setup&amp;nbsp;&lt;SPAN&gt;free-running Rx UART DMA and safely get RX data from the DMA buffer.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am guessing it requires setting DMA DCRx, etc.&lt;/P&gt;&lt;P&gt;And uses SDK APIs like&amp;nbsp;DMA_SetModulo(), etc.&lt;/P&gt;&lt;P&gt;The MCUXpresso UART examples do not include setting up&amp;nbsp;&lt;SPAN&gt;free-running Rx UART DMA.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I read notes from other customer that have the same problem:&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;thread/451044&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you point me to a Kinetis SDK project, with source that sets up&amp;nbsp;&lt;SPAN&gt;free-running Rx UART DMA?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Bruce&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Jul 2019 21:49:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911858#M53445</guid>
      <dc:creator>bgraham</dc:creator>
      <dc:date>2019-07-26T21:49:00Z</dc:date>
    </item>
    <item>
      <title>Re: MKL26Z256 - Can DMA UART RX end transfer on RX idle?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911859#M53446</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Bruce&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The uTasker libraries work with FreeRTOS and SDK (they just don't use SDK HW sources for this particular task since these have poor portability [if you moved to a different Kinetis part they need different libraries whereas uTasker libraries can operate on any chip in a compatible manner]) - &lt;EM&gt;it is just C code that sets up everything you need so can essentially be used in any environment.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are no SDK and no FreeRTOS libraries that allow free-running UART DMA and this restriction has been known for a long time and that is why the uTasker resources have been made available to help out in such situations. FreeRTOS based products with modems have used this technique on KL parts to overcome the restriction.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is an example of a FreeRTOS task using the uTasker free-running Rx DMA resources (which simply echoes back for demonstration purposes):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;static&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;uart_task&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;pvParameters&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
    QUEUE_TRANSFER length &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    QUEUE_HANDLE uart_handle&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;unsigned&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;char&lt;/SPAN&gt; dataByte&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;while&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;uart_handle &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;fnGetUART_Handle&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; NO_ID_ALLOCATED&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;      &lt;SPAN class="comment token"&gt;// get the UART handle&lt;/SPAN&gt;
        &lt;SPAN class="token function"&gt;vTaskDelay&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;500&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;portTICK_RATE_MS&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;                                &lt;SPAN class="comment token"&gt;// wait for 500ms in order to allow uTasker to configure UART interfaces&lt;/SPAN&gt;
    &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
    &lt;SPAN class="token function"&gt;fnDebugMsg&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"FreeRTOS Output\r\n"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;                                   &lt;SPAN class="comment token"&gt;// test a UART transmission&lt;/SPAN&gt;
    &lt;SPAN class="token function"&gt;FOREVER_LOOP&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
        length &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;fnRead&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;uart_handle&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;amp;&lt;/SPAN&gt;dataByte&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;                      &lt;SPAN class="comment token"&gt;// read a byte from the DMA input buffer (returns immediately)&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;length &lt;SPAN class="operator token"&gt;!=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;                                               &lt;SPAN class="comment token"&gt;// if something is available&lt;/SPAN&gt;
            &lt;SPAN class="token function"&gt;fnDebugMsg&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"FreeRTOS Echo:"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;                                &lt;SPAN class="comment token"&gt;// echo it back&lt;/SPAN&gt;
            &lt;SPAN class="token function"&gt;fnWrite&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;uart_handle&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;amp;&lt;/SPAN&gt;dataByte&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;                          &lt;SPAN class="comment token"&gt;// send the byte back&lt;/SPAN&gt;
            &lt;SPAN class="token function"&gt;fnDebugMsg&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"\r\n"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;                                          &lt;SPAN class="comment token"&gt;// with termination&lt;/SPAN&gt;
        &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;                                                           &lt;SPAN class="comment token"&gt;// nothing in the input buffer&lt;/SPAN&gt;
            &lt;SPAN class="token function"&gt;vTaskDelay&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;                                               &lt;SPAN class="comment token"&gt;// wait a single tick to allow other tasks to execute&lt;/SPAN&gt;
        &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
    &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;


‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This gives configurable interrupt/DMA Rx/Tx on any Kinetis UART in uTasker, FreeRTOS or dual-OS (uTasker/FreeRTOS) environments. The particular example checks the DMA input buffer once a Tick but its rate is obviously configurable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See also your thread &lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;thread/451044&lt;/SPAN&gt; - the project was FreeRTOS based and solved by the uTasker resources called from a FreeRTOS task. Following on, the same customer has developed a number of further products using this approach (including the same for HS USB-CDC on the K66 which uses the same approach and gives efficient and reliable USB on any KL or K part with USB) and confirms better performance and faster developments (thus lower development costs). I am sure that the customer will be happy to give more information if you have doubts.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That means that all is available for those needing it. For those needing it but only allowed to use SDK sources, guidelines (as in my last post) are also published as to what is needed in the spirit of helping but it is of course up to them to do the coding of the missing parts themselves. &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;P&gt;&lt;/P&gt;&lt;P&gt;Ref: &lt;A href="https://community.nxp.com/thread/454831" rel="nofollow noopener noreferrer" target="_blank"&gt;https://community.nxp.com/thread/454831&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Jul 2019 23:52:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911859#M53446</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2019-07-26T23:52:43Z</dc:date>
    </item>
    <item>
      <title>Re: MKL26Z256 - Can DMA UART RX end transfer on RX idle?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911860#M53447</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are not listening to me. This is not funny at all.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My MCU is tight on memory, so no utasker crap!&lt;/P&gt;&lt;P&gt;uTasker polls the UART, and polling eats battery, so no utasker crap!&lt;/P&gt;&lt;P&gt;I don't need the over head of utasker, so not utasker crap!&lt;/P&gt;&lt;P&gt;See attached file for details.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Can you provide me with some info about how to setup DMA and UART&lt;/P&gt;&lt;P&gt;for free-running Rx UART DMA?*&lt;/P&gt;&lt;P&gt;This should be 10 lines of code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please don't piss me off with another utasker suggestion.&lt;/P&gt;&lt;P&gt;Have I made myself clear?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bruce&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On Fri, Jul 26, 2019 at 7:53 PM mjbcswitzerland &amp;lt;admin@community.nxp.com&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Jul 2019 13:39:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911860#M53447</guid>
      <dc:creator>bgraham</dc:creator>
      <dc:date>2019-07-29T13:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: MKL26Z256 - Can DMA UART RX end transfer on RX idle?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911861#M53448</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you don't want to poll you just add an IDLE line wake-up event as discussed previously (and the topic of this thread).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There was a thread about 2 months ago where the low level details were discussed, with the code required (that someone managed to get working in a bare metal SDK environment). Unfortunately I can't find this thread anymore otherwise you could have copied that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For low power operations VLPS allows uA operation but will only work up to about 19kBaud due to the time it takes to leave the mode when new UART data arrives (the first character needs to wake via an asynchronous interrupt and not be missed by the HW). For high(er) speed you need to use WAIT mode, which allows free-running DMA with Idle line event but it will only save about 40% over full run mode. To get lower current consumption you will need to see what is the lowest speed you can run the flash and bus clocks but still achieving the reaction times.&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>Mon, 29 Jul 2019 16:57:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911861#M53448</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2019-07-29T16:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: MKL26Z256 - Can DMA UART RX end transfer on RX idle?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911862#M53449</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bruce,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was trying to use the SDK for similar reasons and the same application in FreeRToS. I know you said you dont want to use uTasker but it actually has full FreeRToS support and I have a few projects running in production with it which we're very happy with. I had a large and complex project in FreeRToS and just copied it over to uTasker and called tasks and it works straight away.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unless you want to rework the SDK&amp;nbsp;code to do what you want you'll end up doing what i did and wasting weeks trying to make it do what need, I was actually not able to get the DMA working as I wanted so I was left with trying uTasker which i did, and within a day i was up and running with all my DMA problems solved. I am not sure why the supplied SDK does not have full DMA support for UART but i just does not, their examples and implementation are not really practical.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope all works out for you, but I can tell you from my experience trying to get the standard SDK working ended up with a couple of weeks of pulling my hair out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck Bruce!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Jul 2019 22:33:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911862#M53449</guid>
      <dc:creator>CarlFST60L</dc:creator>
      <dc:date>2019-07-29T22:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: MKL26Z256 - Can DMA UART RX end transfer on RX idle?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911863#M53450</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bruce:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please refer to my attached code , it uses uart DMA with idle line detection to receive some variable-length data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is a bare metal project, and you can port it to SDK.&lt;/P&gt;&lt;P&gt;It was tested with Frdm-kl26 board.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope it helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will create an internal ticket to the developers to integrate the idle line detection demo to SDK.&lt;/P&gt;&lt;P&gt;Thank you all for your good suggestions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Aug 2019 02:58:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911863#M53450</guid>
      <dc:creator>danielchen</dc:creator>
      <dc:date>2019-08-01T02:58:56Z</dc:date>
    </item>
    <item>
      <title>Re: MKL26Z256 - Can DMA UART RX end transfer on RX idle?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911864#M53451</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Beware that this code is not free-running Rx DMA but instead is the fixed length reception with the idle line interrupt signalling that a pause has occurred and resetting the same fixed length DMA transfer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will work in basic situations but suffers from race states when further rx data arrives when the application has not yet handled the content of the reception buffer; &lt;EM&gt;this potential problem could however be overcome by using two different fixed length buffers and swapping between them&lt;/EM&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The second problem that it has is that it still involves a critical interrupt and it cannot guarantee that the first byte of a following message is not lost (overrun), especially at higher Baud rates.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Therefore it demonstrates the operation but is not a fully reliable implementation and thus poses potential problems to product operation and reliability.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With the DMA controller in the KL parts the only method for optimal performance and reliability is to use true free-running techniques based on modular aligned buffers without interrupts controlling DMA configurations.&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>Thu, 01 Aug 2019 22:28:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911864#M53451</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2019-08-01T22:28:39Z</dc:date>
    </item>
    <item>
      <title>Re: MKL26Z256 - Can DMA UART RX end transfer on RX idle?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911865#M53452</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for everyone's input.&lt;/P&gt;&lt;P&gt;I have spent a week trying to get the KL26 UART and DMA to do what I want. I agree with Mark about the overrun problems.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;I have a modem that spits out status strings are unpredictable times.&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;The modem only works at 115200.&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;My app needs to ack as soon as the UART RX goes IDLE.&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;My app also needs to use minimal power, so the MCU needs to sleep until the UART IDLE event occurs.&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;My app uses FreeRTOS, so the solution must work with it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The cause:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;The MCU is in sleep mode, it takes time coming out of sleep before it can handle the UART ISR.&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;The UART hardware overrun occurs before the MCU is awake and completes the UART ISR.&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;NXP solutions that don't work:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;The &lt;SPAN&gt;NXP has provided examples for the&amp;nbsp;&lt;/SPAN&gt;UART and DMA that all the have this problem: by the time the sleeping MCU has waken (clocks clocking, etc), the next char has been received by the UART, and it has overrun.&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;The FreeRTOS UART examples are worse, the receive function waits forever for a fixed length string that it might never receive.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Conclusions:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;With a UART running at 115200 and a sleeping MCU, the use of UART or DMA interrupts will not work. Period.&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A possible solution:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;set the DMA as free running&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;2 DMA buffers&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;a hardware timer called by ISR, not FreeRTOS scheduler&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;a queue with a &lt;SPAN&gt;mutex&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN&gt;xSemaphoreCreateMutex()&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;a FreeRTOS thread that starts the DMA and gets data from the queue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data flow:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;DMA -&amp;gt; Buffer0 or Buffer1 -&amp;gt; timer -&amp;gt; queue -&amp;gt; thread's buffer&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;A FreeRTOS thread w&lt;/SPAN&gt;ould:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Setup 2 DMA buffers.&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Setup a Queue that the timer would copy to, and FreeRTOS thread would copy from.&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN&gt;Setup a periodic timer.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN&gt;Start UART RX and DMA.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A hardware timer ISR would:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Attempt to get the Queue's&amp;nbsp;&lt;SPAN&gt;mutex&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN&gt;xSemaphoreTakeFromISR()&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;If the Queue's&amp;nbsp;&lt;SPAN&gt;mutex&amp;nbsp;&lt;/SPAN&gt;was acquired then&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;STRONG&gt; disable FreeRTOS&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;&lt;STRONG&gt;taskENTER_CRITICAL_FROM_ISR()&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;STRONG&gt;disable the DMA interrupt&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;STRONG&gt;save the count of data in the current DMA buffer&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;STRONG&gt;if (0 &amp;lt; count) then&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;&lt;STRONG&gt;Switch DMA buffers&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;&lt;STRONG&gt;Setup the next DMA transfer&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;STRONG&gt;enable the DMA interrupt&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;STRONG&gt;enable FreeRTOS&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;&lt;STRONG&gt;taskEXIT_CRITICAL_FROM_ISR()&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN&gt;if (0 &amp;lt; count) then&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;Copy data in the DMA buffer to the Queue&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;If the Queue has overrun, then&lt;/P&gt;&lt;P style="padding-left: 120px;"&gt;Set a "overrun" variable&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;release the Queue's&amp;nbsp;&lt;SPAN&gt;mutex&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;&lt;SPAN&gt;xSemaphoreGiveFromISR()&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN&gt;if the Queue has received data then&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;send an event to the FreeRTOS thread to wake it up.&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;xEventGroupSetBitsFromISR()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A&amp;nbsp;&lt;SPAN&gt;FreeRTOS&amp;nbsp;thread&amp;nbsp;&lt;/SPAN&gt;would periodically:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Attempt to get the Queue's&amp;nbsp;&lt;SPAN&gt;mutex&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN&gt;xSemaphoreTake()&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding: 0px 0px 0px 30px;"&gt;If the Queue's mutext was acquired then&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;copy data from the Queue to a string for processing.&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN&gt;Clear the&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;"overrun" variable&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN&gt;release the Queue's mutex&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So far, I have the DMA to filling the DMA buffer without losing any RX data.&lt;/P&gt;&lt;P&gt;I have the queue and mutex working.&lt;/P&gt;&lt;P&gt;But I have not figured out how to SAFELY get the data and setup the next DMA buffer (In bold above).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anybody see a problem with this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Bruce&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Aug 2019 16:41:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911865#M53452</guid>
      <dc:creator>bgraham</dc:creator>
      <dc:date>2019-08-02T16:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: MKL26Z256 - Can DMA UART RX end transfer on RX idle?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911866#M53453</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For low power mode you need to ensure that both DMA and UART are operational so that it can operate in the low power state without restrictions (UART0 clock is more flexible on the KL26 so is advised for more flexible low power clocking in low power modes). You also need to know your uA limit to be able to decide whether a particular mode is possible or not.&lt;BR /&gt;VLPW is potentially interesting assuming you can afford about 250uA current consumption typically and also run the processor at a lower speed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have attached two binaries for the FRDM-KL26Z board that allow the operation that you are looking for and allow the consumption to be measured.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;FreeRTOS_FRDM-KL26_UART_FREERUN_DMA_IDLE_LINE_WAIT.bin&lt;/STRONG&gt; uses a task as follows with semaphore to avoid any polling. The processor waits in WAIT mode (CPU clock stopped but DMA, UART and other enabled peripherals fully active) which saves about 40% consumption compare to when the processor is always running. There is a task flashing an LED periodically but the UART task will wait for a semaphore indefinitely unless it is temporarily released by the idle line interrupt. The UART is in free running DMA mode without any DMA interrupts or need to change buffers and such, which represents the optimal solution&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the task and idle line interrupt callback which is controlling the task operation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="property macro token"&gt;#include &lt;SPAN class="string token"&gt;"semphr.h"&lt;/SPAN&gt;&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;static&lt;/SPAN&gt; SemaphoreHandle_t xSemaphore &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; NULL&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;static&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;uart_task&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;pvParameters&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
    QUEUE_TRANSFER length &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    QUEUE_HANDLE uart_handle&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;unsigned&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;char&lt;/SPAN&gt; dataIn&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;128&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    xSemaphore &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;xSemaphoreCreateBinary&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;                               &lt;SPAN class="comment token"&gt;// creat a binary semaphore&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;while&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;uart_handle &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;fnGetUART_Handle&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; NO_ID_ALLOCATED&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;      &lt;SPAN class="comment token"&gt;// get the UART handle&lt;/SPAN&gt;
        &lt;SPAN class="token function"&gt;vTaskDelay&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;500&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt;portTICK_RATE_MS&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;                                &lt;SPAN class="comment token"&gt;// wait for 500ms in order to allow uTasker to configure UART interfaces&lt;/SPAN&gt;
    &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
    &lt;SPAN class="token function"&gt;fnDebugMsg&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"FreeRTOS Output\r\n"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;                                   &lt;SPAN class="comment token"&gt;// test a UART transmission&lt;/SPAN&gt;
    &lt;SPAN class="token function"&gt;FOREVER_LOOP&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
        &lt;SPAN class="token function"&gt;xSemaphoreTake&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;xSemaphore&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; portMAX_DELAY&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;                       &lt;SPAN class="comment token"&gt;// take semaphore/wait for semaphore to become free (idle line detection)&lt;/SPAN&gt;
        length &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;fnRead&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;uart_handle&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; dataIn&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;sizeof&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;dataIn&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;            &lt;SPAN class="comment token"&gt;// read available data from the DMA input buffer (returns immediately)&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;length &lt;SPAN class="operator token"&gt;!=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;                                               &lt;SPAN class="comment token"&gt;// if something is available&lt;/SPAN&gt;
            &lt;SPAN class="token function"&gt;fnDebugMsg&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"FreeRTOS Echo:"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;                                &lt;SPAN class="comment token"&gt;// echo it back&lt;/SPAN&gt;
            &lt;SPAN class="token function"&gt;fnWrite&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;uart_handle&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; dataIn&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; length&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;                        &lt;SPAN class="comment token"&gt;// send the buffer content back&lt;/SPAN&gt;
            &lt;SPAN class="token function"&gt;fnDebugMsg&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"\r\n"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;                                          &lt;SPAN class="comment token"&gt;// with termination&lt;/SPAN&gt;
        &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
    &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;// Called from UART idle line interrupt&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;//&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;extern&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;int&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;fnSciRxIdle&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;QUEUE_HANDLE channel&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
    &lt;SPAN class="token function"&gt;xSemaphoreGive&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;xSemaphore&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;                                          &lt;SPAN class="comment token"&gt;// allow the UART task to continue&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do use the uTasker low power module and UART driver to do this as it works off-the-bat and, since I am on holiday the next weeks, don't have time to re-write it so that it is doesn't reference existing uTasker library code. You can however attach a debugger and check how the DMA and UART is setup and possibly reverse engineer it from the settings (the library is only setting up the UART, a modulo circular buffer and the DMA).&lt;BR /&gt;Since the FreeRTOS task only echos back reception here is no menu to control low power mode tests in this version.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The second is a pure uTasker project (without FreeRTOS task but using the same libray code - the UART/DMA/Idle line operation is equivalent) - &lt;STRONG&gt;uTasker_FRDM-KL26_UART_FREERUN_DMA_IDLE_LINE_WAIT.bin&lt;/STRONG&gt;. It inherits a menu with low power control in this case so also allows checking the current consumption in the various low power modes and see how the UART is affected in the process. Note that the processor is operating at 48MHz and so not all low power modes are possible in this case (due to max. clocks being exceeded).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The VCOM UART is active in all cases at 115kBaud and the low power menu is in the "administration menu":&lt;BR /&gt;The command "show_lp" shows the available modes which are dynamically switched between when set, with the WAIT mode being set by default (as used by FreeRTOS version):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"show_lp"&lt;BR /&gt;RUN = 0&lt;BR /&gt;WAIT = 1 [active]&lt;BR /&gt;STOP = 2&lt;BR /&gt;PSTOP1 = 3&lt;BR /&gt;PSTOP2 = 4&lt;BR /&gt;VLPR = 5&lt;BR /&gt;VLPW = 6&lt;BR /&gt;VLPS = 7&lt;BR /&gt;VLLS0 = 8&lt;BR /&gt;VLLS1 = 9&lt;BR /&gt;VLLS3 = 10&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The new low power mode can be set with &lt;BR /&gt;"set_lp 2" for example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since I don't have a multi-meter with me I couldn't test the consumption in each case and therefore I also am not sure which of the low power modes are possible/taken.&lt;BR /&gt;It may however give you a starting reference for your own work.&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, 02 Aug 2019 22:46:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911866#M53453</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2019-08-02T22:46:24Z</dc:date>
    </item>
    <item>
      <title>Re: MKL26Z256 - Can DMA UART RX end transfer on RX idle?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911867#M53454</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for trying to help, but uTasker drags in too much extra stuff that will not fit in FLASH.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My current version is mostly working as I described above, but I used a FreeRTOS timer instead of a hardware timer, so I used the non ISR forms of the FreeRTOS APIs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the UART, DMA buffer switching and FreeRTOS timer working.&lt;/P&gt;&lt;P&gt;The code gets the first modem string from the first DMA buffer.&lt;/P&gt;&lt;P&gt;But, after the 2nd DMA buffer is setup, the DMA fails to trainsfer the 2nd modem string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can see that the first char of the 2nd string is getting into the UART's D register, so it seems that the DMA controller has failed to start the 2nd DMA transfer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My timer code is starting the next DMA using DMA_SetTransferConfig() to setup the buffer. It uses DMA_TriggerChannelStart() to start the next DMA transfer by setting the DMA DCR START bit.&lt;/P&gt;&lt;P&gt;See below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;DMA_ResetChannel(baseDMA, channel);&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;// Switch DMA buffers&lt;BR /&gt; switch(s_iCurrentBuffer)&lt;BR /&gt; {&lt;BR /&gt; case 0:&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;memset(s_szBuffer1_DMA, 0, s_iSizeOfBuffers);&lt;BR /&gt; s_dma_transfer_config.destAddr = (uint32_t)s_szBuffer1_DMA;&lt;BR /&gt; s_iCurrentBuffer = 1;&lt;BR /&gt; break;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;case 1:&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;memset(s_szBuffer0_DMA, 0, s_iSizeOfBuffers);&lt;BR /&gt; s_dma_transfer_config.destAddr = (uint32_t)s_szBuffer0_DMA;&lt;BR /&gt; s_iCurrentBuffer = 0;&lt;BR /&gt; break;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;}&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;STRONG&gt;DMA_SetTransferConfig(baseDMA, channel, &amp;amp;s_dma_transfer_config); // Use the saved config&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt; DMA_TriggerChannelStart(baseDMA, channel);&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;UART_EnableInterrupts(baseUART, kUART_RxDataRegFullInterruptEnable);&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;The UART appears to be getting the first char from the modem's 2nd second string.&lt;/P&gt;&lt;P&gt;See DMA0 and UART1 registers below.&lt;/P&gt;&lt;P&gt;DMA-DSR-BCR0 BSY is 1&lt;/P&gt;&lt;P&gt;DMA-DCS0 EINT is 1&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;DMA-DCS0 START was set&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I think the 2nd DMA transfer is not getting started.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What might explain why my 2nd DMA transfer fails to start?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Bruce&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_2.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/86157i6BADBEAE1DCED568/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_2.png" alt="pastedImage_2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Aug 2019 18:46:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911867#M53454</guid>
      <dc:creator>bgraham</dc:creator>
      <dc:date>2019-08-07T18:46:54Z</dc:date>
    </item>
    <item>
      <title>Re: MKL26Z256 - Can DMA UART RX end transfer on RX idle?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911868#M53455</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I found the problem.&lt;/P&gt;&lt;P&gt;Each DMA transfer is clearing DMA-DCR0 ERQ.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To set ERQ, I added&amp;nbsp;DMA_StartTransfer(s_handleDMA-&amp;gt;rxDmaHandle) after&amp;nbsp;DMA_TriggerChannelStart(baseDMA, channel).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Setting ERQ looks like it is working!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for every one's ideas.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I attached the working project.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bruce&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Aug 2019 19:25:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911868#M53455</guid>
      <dc:creator>bgraham</dc:creator>
      <dc:date>2019-08-07T19:25:20Z</dc:date>
    </item>
    <item>
      <title>Re: MKL26Z256 - Can DMA UART RX end transfer on RX idle?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911869#M53456</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What current consumption do you achieve?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that if you have problems with code size make sure that you enable optimisation for size - I see that your debug version generates about 40k code size but your release version (with optimisation for size) is about half the size.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where did you get the code size values for the uTasker FreeRTOS environment from? If I put your tasks in it I get a code size of 15k (with optimisation for size) including all your tasks plus the uTasker DMA interface in a further task, and dynamic low power support. This is what I expect because the environment is designed to be more efficient than the standard HW libraries and allows more application functionality to be achieved in a certain flash size; since your figures suggest that it is the other way round I would be interested to learn where they were taken from so that I can check there is no mistake somewhere.&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>Wed, 07 Aug 2019 22:07:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911869#M53456</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2019-08-07T22:07:38Z</dc:date>
    </item>
    <item>
      <title>Re: MKL26Z256 - Can DMA UART RX end transfer on RX idle?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911870#M53457</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #000000;"&gt;The UART can however be configured to interrupt on idle line and this interrupt then used to check the reception state. The idle line condition however has no interaction with the DMA operation and so code in the idle line interrupt needs to do whatever required.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #51626f; background-color: #ffffff; border: 0px;"&gt;&lt;SPAN style="color: #000000;"&gt;Note that a further advantage of free-running DMA reception over the&lt;/SPAN&gt; &lt;A href="https://www.mycfavisit.reviews/"&gt;&lt;SPAN style="color: #000000;"&gt;MyCFAvisit&lt;/SPAN&gt;&lt;/A&gt;&amp;nbsp;&lt;SPAN style="color: #000000;"&gt;pre-defined reception length is that the fixed reception length method requires the DMA to be set up "again" for the next reception. If the data rate is high it may be that the code is not always fast enough to react to the initial end of DMA interrupt and set up before the start of the next message arrives and is lost (overrun). Free running DMA to a large circular buffer (no firmware intervention needed) ensures that no overrun can occur even at very high data rates.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Aug 2019 05:25:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911870#M53457</guid>
      <dc:creator>royaragon5946</dc:creator>
      <dc:date>2019-08-08T05:25:07Z</dc:date>
    </item>
    <item>
      <title>Re: MKL26Z256 - Can DMA UART RX end transfer on RX idle?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911871#M53458</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I attempted to get it to work by polling the DMA registers. I had the polling routine use the previous and new value of the DMA's DAR to determine where the new data is in the circular buffer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I never got the free-running DMA to work. So, I ended up disabling DMA, swapping buffers, and re-STARTing DMA. The down side of this is that the UART could over flow while the DMA is disabled.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to see how you setup the DMA and UART for&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;free-running DMA&lt;/SPAN&gt;. This appears to be a better solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bruce&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Aug 2019 13:51:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911871#M53458</guid>
      <dc:creator>bgraham</dc:creator>
      <dc:date>2019-08-08T13:51:10Z</dc:date>
    </item>
    <item>
      <title>Re: MKL26Z256 - Can DMA UART RX end transfer on RX idle?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911872#M53459</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My test app has not power management.&lt;/P&gt;&lt;P&gt;My target app does power management in the FreeRTOS&amp;nbsp;vApplicationIdleHook().&lt;/P&gt;&lt;P&gt;When the Idle task runs, it puts the MCU to sleep.&lt;/P&gt;&lt;P&gt;The MCU wakes when an interrupt occurs.&lt;/P&gt;&lt;P&gt;My state machines are event driven. They regularly wake after a timeout.&lt;/P&gt;&lt;P&gt;When an interrupt occurs, the FreeRTOS scheduler resumes, the state machines run and then wait for another event.&lt;/P&gt;&lt;P&gt;The MCU is typically asleep 99.999% of the time.&lt;/P&gt;&lt;P&gt;I measured the current drawn from the battery and this saved me 2.5 mA.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since my code is directly managing DMA registers, it is about as minimal as it can get.&lt;/P&gt;&lt;P&gt;I would like to see if using free running DMA code would use less memory and MCU cycles.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I looked at the uTasker code. It is executing lots of code that makes it portable. I can't afford that over head. This project will never be ported to another MCU, so why not manage the DMA registers directly?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bruce&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Aug 2019 14:19:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911872#M53459</guid>
      <dc:creator>bgraham</dc:creator>
      <dc:date>2019-08-08T14:19:33Z</dc:date>
    </item>
    <item>
      <title>Re: MKL26Z256 - Can DMA UART RX end transfer on RX idle?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911873#M53460</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bruce&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to reduce code overhead you can remove printf() since it draws in a large amount of overhead and also (unnecessarily) uses malloc().&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The uTasker code gives smaller projects that the standard libraries, even if it is portable - I get 25% lower flash utilisation than your present project when doing the same functionality with FreeRTOS. This has been confirmed in various FreeRTOS based products where interesting code and RAM savings have been seen. In case of uTasker USB and TCP/IP stacks smaller code sizes of the order of 50k..100k less code are often experienced.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2.5mA saving when using WAIT mode is as expected so the operation is correct. In most projects the CPU is running only 0.01% of the time when the system is event driven. (I assume that you are at around 4mA average at 48MHz, whereby I think that you should be able to get down to around 250uA using lower power modes, without UART data loss).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You'll get the same code size with free-running DMA, but it will ensure no possible data loss when swapping DMA buffers. If you use a part with eDMA also buffer swapping can be performed without race states due to the fact that it supports half buffer interrupts but the simpler DMA in the KL parts has no DMA running when swapping and so can potentially lose data. In your case at 115k Baud DMA is however not needed (unless you were to have higher priority interrupts or such causing high interrupt latency) since interrupt handling of each character is fast enough [some KL, KE parts have no DMA and the products that I have developed using such have not knowingly ever lost data at 115kBaud]. If there is not a lot of traffic there will also not be any noticeably higher average current consumption as a result of interrupt operation as opposed to DMA driven modes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I have time this weekend I will show you how to modify your code to use true free-running DMA. I am still convinced that there is a thread somewhere explaining its operation and showing the code needed (for the KL parts) but I haven't been able to find it again so I will repeat it so that it doesn't get lost again.&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>Thu, 08 Aug 2019 23:04:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911873#M53460</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2019-08-08T23:04:31Z</dc:date>
    </item>
    <item>
      <title>Re: MKL26Z256 - Can DMA UART RX end transfer on RX idle?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911874#M53461</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mark,&lt;/P&gt;&lt;P&gt;If you could find the notes for free-running DMA, that would greatly help.&lt;/P&gt;&lt;P&gt;I am not sure my double buffering is 100% reliable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To setup free-running DMA for UART RX I think I need something like below.&lt;/P&gt;&lt;P&gt;I am assuming that the BCR is the only register that is used at run time.&lt;/P&gt;&lt;P&gt;See below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since &lt;SPAN&gt;DMOD is set,&amp;nbsp;&lt;/SPAN&gt;I am assuming the BCR will roll over as the buffer fills.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;How do I detect overflow of the DMA buffer?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Will UART Framing and Noise errors cause the DMA to halt?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Bruce&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;STRONG&gt;SETUP:&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;DMOD -&amp;nbsp;Destination Address Modulo&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0111 Circular buffer size is 1 KB&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;DAR -&amp;nbsp;Destination Address Register&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;set to point to p&lt;SPAN&gt;Buffer,&amp;nbsp;&lt;/SPAN&gt;a 1KB buffer&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;BCR -&amp;nbsp;&lt;SPAN&gt;This field contains the number of bytes yet to be transferred for a given block.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;set to 0x40 (1024 bytes)&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;STRONG&gt;START:&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;START -&amp;nbsp;Start Transfer&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; set to 1&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;STRONG&gt;RUN TIME:&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;newBCR = BCR.&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;BR /&gt;if newBCR &amp;lt; previousBCR&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&lt;STRONG&gt;876543210 BCR values from end&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&lt;STRONG&gt; 012345678 index into Buffer&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&lt;STRONG&gt; xxxABCxxx Example data "ABC" in Buffer[]&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;previousBCR == 6&lt;BR /&gt; newBCR == 3&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;iStart1 = sizeof(Buffer) - previousBCR&lt;BR /&gt; = 9 - 6&lt;BR /&gt; = 3&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;pData1 = &amp;amp;Buffer[iStart1]&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;length1 = previousBCR -&amp;nbsp;&lt;SPAN&gt;newBCR&lt;/SPAN&gt;&lt;BR /&gt; = 6 - 3&lt;BR /&gt; = 3&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;else if previousBCR &amp;lt; newBCR&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&lt;STRONG&gt;876543210 BCR values from end&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&lt;STRONG&gt; 012345678 index into Buffer&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;&lt;STRONG&gt; CxxxxxxAB&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Example data "ABC" in Buffer[]&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;previousBCR == 2&lt;BR /&gt; newBCR == 8&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;iStart1 = sizeof(Buffer) - previousBCR&lt;BR /&gt; = 9 - 2&lt;BR /&gt; = 7&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;pData1 = &amp;amp;Buffer[iStart1]&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;length1 = previousBCR&lt;BR /&gt; = 2&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;BR /&gt; pData2 = &amp;amp;Buffer[0]&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;length2 = newBCR - 1&lt;BR /&gt; = 2 - 1&lt;BR /&gt; = 1&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;BR /&gt;else&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;no data&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;previousBCR = newBCR&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Aug 2019 19:30:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/MKL26Z256-Can-DMA-UART-RX-end-transfer-on-RX-idle/m-p/911874#M53461</guid>
      <dc:creator>bgraham</dc:creator>
      <dc:date>2019-08-09T19:30:18Z</dc:date>
    </item>
  </channel>
</rss>

