<?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 Design StudioのトピックRe: Processor Expert Asynchronous Serial Race Condition?</title>
    <link>https://community.nxp.com/t5/Kinetis-Design-Studio/Processor-Expert-Asynchronous-Serial-Race-Condition/m-p/637910#M8191</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Mark,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry i can not clearly know the problem.&lt;/P&gt;&lt;P&gt;Could you please tell me what function you want to realize , and you can&lt;/P&gt;&lt;P&gt;also send your project to me , then we can refer to it to analyze your 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, 17 Oct 2016 10:02:51 GMT</pubDate>
    <dc:creator>Alice_Yang</dc:creator>
    <dc:date>2016-10-17T10:02:51Z</dc:date>
    <item>
      <title>Processor Expert Asynchronous Serial Race Condition?</title>
      <link>https://community.nxp.com/t5/Kinetis-Design-Studio/Processor-Expert-Asynchronous-Serial-Race-Condition/m-p/637909#M8190</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Again I am running into nuisance problems in Processor Expert. This time I am running into problems with the Serial_LDD on the MKV31F512VLL12 processor.&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have events for OnBlockReceived, OnBlockSent, and OnTxComplete all turned on. In each of these interrupts I have a volatile flag set to TRUE when these events complete.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is when I make multiple calls to the following routine:&lt;/P&gt;&lt;PRE&gt;&lt;PRE&gt;/************************************************
 * Send a string to the console. If entering here
 * before send is complete, this will block until
 * previous send has completed.
 */
void AS1_SendString(char *null_term_string)
{
 uint16_t len;

 if (mySerialPtr == NULL) return;

 len = strlen(null_term_string);
 //Cap length, these are strings after all, not full data.
 if (len &amp;gt; MAX_SEND_STRING_LEN) len = MAX_SEND_STRING_LEN;

 //Wait for previous send to fully complete.
 while(globals.AS1_TXComplete == FALSE)
 {
 }

 Error = ERR_BUSY;
 //Wait for all bytes to be put into the queue.
 while (Error == ERR_BUSY)
 {
 //Wait until completely sent to begin another.
 Error = AS1_SendBlock(mySerialPtr, null_term_string, len);
 //Flag that new block has not yet been sent.
 globals.AS1_DataSent = FALSE;
 globals.AS1_TXComplete = FALSE;
 }
}

&lt;/PRE&gt;&lt;/PRE&gt;&lt;P&gt;It trashes the completion of the previous send, the last byte in the previous send gets aborted. It wold be the assumption that the&amp;nbsp;&lt;SPAN&gt;OnTxComplete() interrupt should fire &lt;STRONG&gt;after&lt;/STRONG&gt; the last bit goes out hardware-wise, and then the AS1_SendBlock() will also not report busy, but it appears the interrupt for AS1_OnTxComplete() fires at the &lt;STRONG&gt;start&lt;/STRONG&gt; of the last byte transmission, and then the call to AS1_SendBlock() thinks all is ready (as there are no bytes left in the buffer), and the next send setup trashes the last byte currently in-progress.&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&gt;I am able to add a delay and make it work in order to allow that last byte to complete, but of course that is certainly not ideal on a high-performance DSC as the less blocking, the better.&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&gt;Any suggestions on a work-around to prevent needing to spin a delay in this code? I am trying to dump data arrays to a console for analysis, and getting lost characters. I suppose I could set up a massive buffer and dump the whole thing at once and avoid the problem, but I would like to get to the bottom of this one.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Oct 2016 16:06:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Design-Studio/Processor-Expert-Asynchronous-Serial-Race-Condition/m-p/637909#M8190</guid>
      <dc:creator>markwyman</dc:creator>
      <dc:date>2016-10-14T16:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: Processor Expert Asynchronous Serial Race Condition?</title>
      <link>https://community.nxp.com/t5/Kinetis-Design-Studio/Processor-Expert-Asynchronous-Serial-Race-Condition/m-p/637910#M8191</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Mark,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry i can not clearly know the problem.&lt;/P&gt;&lt;P&gt;Could you please tell me what function you want to realize , and you can&lt;/P&gt;&lt;P&gt;also send your project to me , then we can refer to it to analyze your 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, 17 Oct 2016 10:02:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Design-Studio/Processor-Expert-Asynchronous-Serial-Race-Condition/m-p/637910#M8191</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2016-10-17T10:02:51Z</dc:date>
    </item>
    <item>
      <title>Re: Processor Expert Asynchronous Serial Race Condition?</title>
      <link>https://community.nxp.com/t5/Kinetis-Design-Studio/Processor-Expert-Asynchronous-Serial-Race-Condition/m-p/637911#M8192</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I did find the issue. It was me. I was not copying over the data I wished to send into a separate buffer before sending, but instead sending the buffer I was actively modifying directly. This led me to some odd conclusions, but obviously not the right ones! I made the erroneous assumption that the SendBlock() provided buffering for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have been doing hardware design and board layouts too long, I guess I am a bit rusty.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry about the false alert.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Corrected:&lt;/P&gt;&lt;PRE&gt;/************************************************
 * Send a string to the console. If entering here
 * before send is complete, this will block until
 * previous send has completed.
 */
void AS1_SendString(char *null_term_string)
{
 uint16_t len;

 //If driver not yet setup, exit.
 if (mySerialPtr == NULL) return;

 //Wait until prior send is complete before over-writing the buffer.
 while (globals.AS1_TXComplete == FALSE)
 {
 }

 //Copy just the bytes we wish to send, len ends with count of bytes.
 for (len = 0; (len &amp;lt; MAX_SEND_STRING_LEN) &amp;amp;&amp;amp; (null_term_string[len] != 0x00); len++)
 {
 uart_outp_data[len] = null_term_string[len];
 }

 //Send the data...
 Error = AS1_SendBlock(mySerialPtr, uart_outp_data, len);
 globals.AS1_TXComplete = FALSE;
}

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Oct 2016 16:23:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Design-Studio/Processor-Expert-Asynchronous-Serial-Race-Condition/m-p/637911#M8192</guid>
      <dc:creator>markwyman</dc:creator>
      <dc:date>2016-10-17T16:23:01Z</dc:date>
    </item>
  </channel>
</rss>

