<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Kinetis Software Development KitのトピックRe: Why need to delay some time to get the correct data after check the LPUART_DRV_EdmaGetReceiveStatus?</title>
    <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Why-need-to-delay-some-time-to-get-the-correct-data-after-check/m-p/637136#M6831</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Hanson He&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry for the late, How is your customer issue status? I'm working on this and I will inform you of anything that I find as soon as possible&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a great day,&lt;BR /&gt;Jorge Alcala&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 01 Feb 2017 22:21:18 GMT</pubDate>
    <dc:creator>jorge_a_vazquez</dc:creator>
    <dc:date>2017-02-01T22:21:18Z</dc:date>
    <item>
      <title>Why need to delay some time to get the correct data after check the LPUART_DRV_EdmaGetReceiveStatus?</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Why-need-to-delay-some-time-to-get-the-correct-data-after-check/m-p/637135#M6830</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Customer use K81, KSDK1.3 version, and have below question,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why need to delay some time to get the new data after check the LPUART_DRV_EdmaGetReceiveStatus?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the question description:&lt;/P&gt;&lt;P&gt;LPUART_DRV_EdmaGetReceiveStatus(LPUART2_IDX, &amp;amp;uiCnt);&lt;/P&gt;&lt;P&gt;// We check uiCnt whether have new data,&lt;BR /&gt;// When&amp;nbsp;UART have new data, we check from &lt;SPAN&gt;LPUART_DRV_EdmaGetReceiveStatus function, then read the DMA buffer data, the data is not latest data, we need to delay some time to get the buffer data after check the &amp;nbsp;LPUART_DRV_EdmaGetReceiveStatus function. If we delay 100us to read, we could got the latest correct data from&amp;nbsp;s_aucRxBuf.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//&amp;nbsp;Resource using is as below:&lt;BR /&gt;//1. LPUART2 receive use DMA function&lt;BR /&gt;//2. DMA BUF is 1024, it receive 200 bytes at one time&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;// DMA&amp;nbsp;Init&lt;BR /&gt;int EdmaInit(void)&lt;BR /&gt;{&lt;BR /&gt; // Init eDMA modules.&lt;BR /&gt; edmaUserConfig.chnArbitration = kEDMAChnArbitrationRoundrobin;&lt;BR /&gt; edmaUserConfig.notHaltOnError = false;&lt;BR /&gt; EDMA_DRV_Init(&amp;amp;edmaState, &amp;amp;edmaUserConfig); &lt;BR /&gt; return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// LPUART2&amp;nbsp;receive DMA init&lt;BR /&gt;int Lpuart2eDmaInit(void)&lt;BR /&gt;{&lt;BR /&gt; unsigned char uartchn;&lt;BR /&gt; lpuart_edma_user_config_t uartConfig;&lt;BR /&gt; &lt;BR /&gt; uartConfig.clockSource = BOARD_LPUART_CLOCK_SOURCE;&lt;BR /&gt; uartConfig.baudRate = 115200;&lt;BR /&gt; uartConfig.bitCountPerChar = kLpuart8BitsPerChar;&lt;BR /&gt; uartConfig.parityMode = kLpuartParityDisabled;&lt;BR /&gt; uartConfig.stopBitCount = kLpuartOneStopBit;&lt;BR /&gt; &lt;BR /&gt; LPUART_DRV_EdmaInit(LPUART2_IDX, &amp;amp;uartEdmaState, &amp;amp;uartConfig);&lt;/P&gt;&lt;P&gt;uartchn = LPUART2_IDX;&lt;BR /&gt; EDMA_DRV_InstallCallback(&amp;amp;uartEdmaState.edmaLpuartRx, Lpuart2EdmaRx_callback, &amp;amp;uartchn);&lt;BR /&gt; return 0; &lt;BR /&gt;}&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// UART receive DMA config&lt;BR /&gt;void UartStartRecv(void)&lt;BR /&gt;{&lt;BR /&gt; LPUART_DRV_EdmaAbortReceivingData(LPUART2_IDX);&lt;BR /&gt; LPUART_DRV_EdmaReceiveData(LPUART2_IDX, s_aucRxBuf, 1024); // config buffer and size&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;void Lpuart2EdmaRx_callback(void *parameter, edma_chn_status_t status)&lt;BR /&gt;{&lt;BR /&gt; /* Stop DMA channel. */&lt;BR /&gt; EDMA_DRV_StopChannel(&amp;amp;lpuartEdmaState.edmaLpuartRx);&lt;/P&gt;&lt;P&gt;/* Signal the synchronous completion object. */&lt;BR /&gt; if (lpuartEdmaState.isRxBlocking)&lt;BR /&gt; {&lt;BR /&gt; OSA_SemaPost(&amp;amp;lpuartEdmaState.rxIrqSync);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;/* Update the information of the module driver state */&lt;BR /&gt; lpuartEdmaState.isRxBusy = false;&lt;/P&gt;&lt;P&gt;UartStartRecv();&lt;BR /&gt;}&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// UART&amp;nbsp;receive function&lt;BR /&gt;u16 UartRxData(u8 *pDataBuf, u16 usLen)&lt;BR /&gt;{&lt;BR /&gt; u32 ulAvailLen = 0;&lt;BR /&gt; u32 ulBufWritePt;&lt;BR /&gt; unsigned int uiRC;&lt;BR /&gt; unsigned int uiCnt;&lt;BR /&gt; unsigned short usNowBufSaveLen;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; LPUART_DRV_EdmaGetReceiveStatus(LPUART2_IDX, &amp;amp;uiCnt);&lt;BR /&gt; &lt;/P&gt;&lt;P&gt;// We check uiCnt whether have new data&lt;BR /&gt;// If got the new data, we read the DMA buffer data, the data is not the latest data, we need to delay some time to get&lt;/P&gt;&lt;P&gt;// the buffer data.&amp;nbsp;If we delay some time to read, such as 100us, we could got the correct data from s_aucRxBuf.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;unsigned char Buf[1024];&lt;/P&gt;&lt;P&gt;void main()&lt;BR /&gt;{&lt;BR /&gt; EdmaInit();&lt;BR /&gt; configure_lpuart_pins(LPUART2_IDX); // LPUART2&amp;nbsp;pin init&lt;BR /&gt; Lpuart2eDmaInit();&lt;BR /&gt; &lt;BR /&gt; while(1)&lt;BR /&gt; {&lt;BR /&gt; UartRxData(Buf, 256); //Why this interface function have delay when read data&lt;BR /&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 22 Jan 2017 08:02:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Why-need-to-delay-some-time-to-get-the-correct-data-after-check/m-p/637135#M6830</guid>
      <dc:creator>hansonhe</dc:creator>
      <dc:date>2017-01-22T08:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: Why need to delay some time to get the correct data after check the LPUART_DRV_EdmaGetReceiveStatus?</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Why-need-to-delay-some-time-to-get-the-correct-data-after-check/m-p/637136#M6831</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Hanson He&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry for the late, How is your customer issue status? I'm working on this and I will inform you of anything that I find as soon as possible&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a great day,&lt;BR /&gt;Jorge Alcala&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Feb 2017 22:21:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Why-need-to-delay-some-time-to-get-the-correct-data-after-check/m-p/637136#M6831</guid>
      <dc:creator>jorge_a_vazquez</dc:creator>
      <dc:date>2017-02-01T22:21:18Z</dc:date>
    </item>
    <item>
      <title>Re: Why need to delay some time to get the correct data after check the LPUART_DRV_EdmaGetReceiveStatus?</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Why-need-to-delay-some-time-to-get-the-correct-data-after-check/m-p/637137#M6832</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Hanson He&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you share the project from your customer, or at least the main.c file, I don't see where you start to receive data. I saw that you have:&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;UartStartRecv&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="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&lt;SPAN class="token function"&gt;LPUART_DRV_EdmaAbortReceivingData&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;LPUART2_IDX&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token function"&gt;LPUART_DRV_EdmaReceiveData&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;LPUART2_IDX&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; s_aucRxBuf&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1024&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;// config buffer and size&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but this function is inside the Lpuart2EdmaRx_callback, and this callback will be called when receive data register is full (this is set in LPUART_DRV_EdmaInit). So you aren't going to be able to received data until you call the function of receive data, and this is contradictory. I cannot prove this code in my side.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Waiting for your reply&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;&lt;P&gt;Jorge Alcala&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Feb 2017 00:31:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Why-need-to-delay-some-time-to-get-the-correct-data-after-check/m-p/637137#M6832</guid>
      <dc:creator>jorge_a_vazquez</dc:creator>
      <dc:date>2017-02-03T00:31:56Z</dc:date>
    </item>
  </channel>
</rss>

