<?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 UART Ring Buffer with DMA using SDK in S32K</title>
    <link>https://community.nxp.com/t5/S32K/UART-Ring-Buffer-with-DMA-using-SDK/m-p/1433574#M14607</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I need to implement a ring buffer for receiving from UART via DMA. For consistency, I'd like to keep using the SDK.&lt;/P&gt;&lt;P&gt;What I want is to set up UART and DMA once, and have a circular buffer that overwrites itself over and over, completely unattended (I can't miss a character, ISR to switch buffer would be too slow). I'll have a periodic task reading from the ring buffer.&lt;/P&gt;&lt;P&gt;The thing is, I just cannot figure out how to do it. The most obvious way I've tried breaks the SDK's abstraction, making it (very) leaky, and also doesn't work:&lt;/P&gt;&lt;P&gt;Looking into edma_driver.h, there is this function EDMA_DRV_ConfigLoopTransfer() which looked to akin to EDMA_DRV_ConfigMultiBlockTransfer() that the UART driver uses. I could find a Freescale document recommending it, but the SDK back there seemed different back then and it tells me to call &lt;SPAN&gt;EDMA_DRV_RequestChannel() beforehand, which is not available anymore&lt;/SPAN&gt;: &lt;A href="https://www.nxp.com/docs/en/supporting-information/Enhanced-Direct-Memory-Access-Controller-Training.pdf" target="_self"&gt;https://www.nxp.com/docs/en/supporting-information/Enhanced-Direct-Memory-Access-Controller-Training.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I tried:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;commenting out the parts of the UART driver that stopped the DMA, that just made the DMA write outside the buffer's limit.&lt;/LI&gt;&lt;LI&gt;making my own function to activate DMA and UART's DMA requests using EDMA_DRV_ConfigLoopTransfer (InitUartDmaReceive()), that leads to DefaultISR on the first char.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;So, is there a sensible way to do it? Or is the SDK really just lacking and I have to fiddle with registers?&lt;/P&gt;&lt;P&gt;Attached, a test project of mine. #define DMA_LOOP turns on the looping attempt. Using S32K148EVB-Q176.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;</description>
    <pubDate>Fri, 25 Mar 2022 02:01:30 GMT</pubDate>
    <dc:creator>thosewhowish2b</dc:creator>
    <dc:date>2022-03-25T02:01:30Z</dc:date>
    <item>
      <title>UART Ring Buffer with DMA using SDK</title>
      <link>https://community.nxp.com/t5/S32K/UART-Ring-Buffer-with-DMA-using-SDK/m-p/1433574#M14607</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I need to implement a ring buffer for receiving from UART via DMA. For consistency, I'd like to keep using the SDK.&lt;/P&gt;&lt;P&gt;What I want is to set up UART and DMA once, and have a circular buffer that overwrites itself over and over, completely unattended (I can't miss a character, ISR to switch buffer would be too slow). I'll have a periodic task reading from the ring buffer.&lt;/P&gt;&lt;P&gt;The thing is, I just cannot figure out how to do it. The most obvious way I've tried breaks the SDK's abstraction, making it (very) leaky, and also doesn't work:&lt;/P&gt;&lt;P&gt;Looking into edma_driver.h, there is this function EDMA_DRV_ConfigLoopTransfer() which looked to akin to EDMA_DRV_ConfigMultiBlockTransfer() that the UART driver uses. I could find a Freescale document recommending it, but the SDK back there seemed different back then and it tells me to call &lt;SPAN&gt;EDMA_DRV_RequestChannel() beforehand, which is not available anymore&lt;/SPAN&gt;: &lt;A href="https://www.nxp.com/docs/en/supporting-information/Enhanced-Direct-Memory-Access-Controller-Training.pdf" target="_self"&gt;https://www.nxp.com/docs/en/supporting-information/Enhanced-Direct-Memory-Access-Controller-Training.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I tried:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;commenting out the parts of the UART driver that stopped the DMA, that just made the DMA write outside the buffer's limit.&lt;/LI&gt;&lt;LI&gt;making my own function to activate DMA and UART's DMA requests using EDMA_DRV_ConfigLoopTransfer (InitUartDmaReceive()), that leads to DefaultISR on the first char.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;So, is there a sensible way to do it? Or is the SDK really just lacking and I have to fiddle with registers?&lt;/P&gt;&lt;P&gt;Attached, a test project of mine. #define DMA_LOOP turns on the looping attempt. Using S32K148EVB-Q176.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;</description>
      <pubDate>Fri, 25 Mar 2022 02:01:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/UART-Ring-Buffer-with-DMA-using-SDK/m-p/1433574#M14607</guid>
      <dc:creator>thosewhowish2b</dc:creator>
      <dc:date>2022-03-25T02:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: UART Ring Buffer with DMA using SDK</title>
      <link>https://community.nxp.com/t5/S32K/UART-Ring-Buffer-with-DMA-using-SDK/m-p/1434772#M14637</link>
      <description>&lt;P&gt;Hi Wesley,&lt;/P&gt;
&lt;P&gt;the SDK does not cover 100% functionality of the microcontroller. The DMA module itself allows us to handle almost all operations and situations we can think about. However, the UART driver does not cover this use-case. As we do not support modifications of SDK code, this should be implemented rather by your own code.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Lukas&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 10:46:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/UART-Ring-Buffer-with-DMA-using-SDK/m-p/1434772#M14637</guid>
      <dc:creator>lukaszadrapa</dc:creator>
      <dc:date>2022-03-28T10:46:20Z</dc:date>
    </item>
  </channel>
</rss>

