<?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 Code example for UART receive?  ReceiveDataBlocking, or with a callback function? in Kinetis Software Development Kit</title>
    <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Code-example-for-UART-receive-ReceiveDataBlocking-or-with-a/m-p/444392#M2913</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am using Kinetis Design Studio 3.0.0 on Win7 and my target is Kinetis MKL16Z32VFT4.&amp;nbsp; I have lpsciCom1 / UART0 set up through Processor Expert, I am using 256000 baud 8/N/1 and the UART transmit side works fine with such commands as: &lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; LPSCI_DRV_SendDataBlocking(FSL_LPSCICOM1, outString, length, 50);&amp;nbsp; // port, buffer, # bytes, timeout&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having trouble with understanding how the UART Receive function should work.&amp;nbsp; For example, if I do&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 1.5;"&gt;&amp;nbsp; status = LPSCI_DRV_ReceiveDataBlocking(FSL_LPSCICOM1, rxString, 2, 50);&amp;nbsp; // receive serial data from external control device&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 1.5;"&gt;the return 'status' value is always 0, regardless if anything was received or not. How do I know how many bytes have been received, if any?&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 1.5;"&gt;I gather there is way to receive data using a callback function, but I have been unable to find any simple examples of such code. I have a very simple application, without any RTOS.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 24 Jul 2015 21:53:32 GMT</pubDate>
    <dc:creator>johnbeale</dc:creator>
    <dc:date>2015-07-24T21:53:32Z</dc:date>
    <item>
      <title>Code example for UART receive?  ReceiveDataBlocking, or with a callback function?</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Code-example-for-UART-receive-ReceiveDataBlocking-or-with-a/m-p/444392#M2913</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am using Kinetis Design Studio 3.0.0 on Win7 and my target is Kinetis MKL16Z32VFT4.&amp;nbsp; I have lpsciCom1 / UART0 set up through Processor Expert, I am using 256000 baud 8/N/1 and the UART transmit side works fine with such commands as: &lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; LPSCI_DRV_SendDataBlocking(FSL_LPSCICOM1, outString, length, 50);&amp;nbsp; // port, buffer, # bytes, timeout&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having trouble with understanding how the UART Receive function should work.&amp;nbsp; For example, if I do&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 1.5;"&gt;&amp;nbsp; status = LPSCI_DRV_ReceiveDataBlocking(FSL_LPSCICOM1, rxString, 2, 50);&amp;nbsp; // receive serial data from external control device&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 1.5;"&gt;the return 'status' value is always 0, regardless if anything was received or not. How do I know how many bytes have been received, if any?&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 1.5;"&gt;I gather there is way to receive data using a callback function, but I have been unable to find any simple examples of such code. I have a very simple application, without any RTOS.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jul 2015 21:53:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Code-example-for-UART-receive-ReceiveDataBlocking-or-with-a/m-p/444392#M2913</guid>
      <dc:creator>johnbeale</dc:creator>
      <dc:date>2015-07-24T21:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: Code example for UART receive?  ReceiveDataBlocking, or with a callback function?</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Code-example-for-UART-receive-ReceiveDataBlocking-or-with-a/m-p/444393#M2914</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;On further investigation, I have seen a value of &lt;/P&gt;&lt;P&gt;&amp;nbsp; kStatus_LPSCI_Timeout = 0x0C&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;returned from the Rx call when there was no data.&amp;nbsp; Before I may have been receiving the tail end of my previous transmission (RS-422 half-duplex circuit gives me a built-in loopback).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jul 2015 22:13:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Code-example-for-UART-receive-ReceiveDataBlocking-or-with-a/m-p/444393#M2914</guid>
      <dc:creator>johnbeale</dc:creator>
      <dc:date>2015-07-24T22:13:33Z</dc:date>
    </item>
    <item>
      <title>Re: Code example for UART receive?  ReceiveDataBlocking, or with a callback function?</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Code-example-for-UART-receive-ReceiveDataBlocking-or-with-a/m-p/444394#M2915</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So do you still have any question ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR&lt;/P&gt;&lt;P&gt;Alice&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Jul 2015 02:12:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Code-example-for-UART-receive-ReceiveDataBlocking-or-with-a/m-p/444394#M2915</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2015-07-27T02:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: Code example for UART receive?  ReceiveDataBlocking, or with a callback function?</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Code-example-for-UART-receive-ReceiveDataBlocking-or-with-a/m-p/444395#M2916</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The blocking receving is done by checking a sync flag set (or a semaphore in RTOS environment) with a timeout para. A background interrupt works with UART controller to try to receive the exact number of bytes you speicifed through API LPSCI_DRV_ReceiveDataBlocking(), when all bytes are received, the call return kStatus_LPSCI_Success. If Timeout is reached, the call return kStatus_LPSCI_Timeout. So there is no situation when this function get data less than you want. Only two results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can't understand your case about "Before I may have been receiving the tail end of my previous transmission (RS-422 half-duplex circuit gives me a built-in loopback)", could you explain more?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In a common case, uart receive interrupt should be enabled always to prevent when peer send data out and uart receive is disabled.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Jul 2015 07:44:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Code-example-for-UART-receive-ReceiveDataBlocking-or-with-a/m-p/444395#M2916</guid>
      <dc:creator>neoxiong</dc:creator>
      <dc:date>2015-07-27T07:44:22Z</dc:date>
    </item>
    <item>
      <title>Re: Code example for UART receive?  ReceiveDataBlocking, or with a callback function?</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Code-example-for-UART-receive-ReceiveDataBlocking-or-with-a/m-p/444396#M2917</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have another device transmitting&amp;nbsp; a long string of characters to my device, but I never receive more than one character at a time and I get the "timeout" flag 0x0C. Maybe I don't have an interrupt turned on? I don't know if this is the right place to post a code example, but I would benefit from some kind of tutorial or example code showing a working UART in receive mode.&amp;nbsp; Is there anything online like that?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Jul 2015 17:59:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/Code-example-for-UART-receive-ReceiveDataBlocking-or-with-a/m-p/444396#M2917</guid>
      <dc:creator>johnbeale</dc:creator>
      <dc:date>2015-07-27T17:59:24Z</dc:date>
    </item>
  </channel>
</rss>

