<?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>8-bit MicrocontrollersのトピックRe: Overrun detection needed for reliable SCI reception?</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Overrun-detection-needed-for-reliable-SCI-reception/m-p/234448#M19458</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Johan,&lt;/P&gt;&lt;BLOCKQUOTE&gt;
&lt;P&gt;Johan Forslöf wrote:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;I've double-checked the compiler output and CodeWarrior does indeed generate loads for these statements. Unfortunately storing the result to a volatile dummy variable generates an additional write of the result to the stack, increasing the window of opportunity for this particular issue by a couple of cycles. I don't suppose there's a more efficient way of reliably forcing the desired behaviour?&lt;/P&gt;
 &lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have never had a problem with the CW compiler providing a read for a volatile register.&amp;nbsp; However, an alternative method would be to provide macros that use HLI assembler to generate the read process, without the overhead of creating, and writing to a variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;#define&amp;nbsp; SCIS1_read&amp;nbsp; __asm lda SCIS1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;#define&amp;nbsp; SCID_read&amp;nbsp;&amp;nbsp; __asm lda SCID&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 24 Mar 2013 14:45:11 GMT</pubDate>
    <dc:creator>bigmac</dc:creator>
    <dc:date>2013-03-24T14:45:11Z</dc:date>
    <item>
      <title>Overrun detection needed for reliable SCI reception?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Overrun-detection-needed-for-reliable-SCI-reception/m-p/234439#M19449</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Basically I'm having trouble with a overruns causing a simple SCI receiver getting stuck in a state where no further interrupts can occur.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems if overrun occurring between polling SCIS1 and reading SCID leaves the peripheral with RDRF cleared but no longer receiving data, until the buffer is flushed by polling SCID.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class="c++" name="code"&gt;__interrupt VectorNumber_Vscirx void ReceiveInterrupt(void) { &amp;nbsp;&amp;nbsp;&amp;nbsp; char data; &amp;nbsp;&amp;nbsp;&amp;nbsp; (void) SCIS1; &amp;nbsp;&amp;nbsp;&amp;nbsp; // The problematic overflow occurs here &amp;nbsp;&amp;nbsp;&amp;nbsp; data = SCID; }&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the record this happens on both 9S08QE8 and 9S08SH8 but not in the full-chip simulator.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This has rather caught me by surprise as I've previously always just ignored UART errors and this leaves me with a lot of potentially vulnerable old code across various Freescale devices to fix up, possibly even on MCUs from other manufacturers.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So what is the intended way of reliably reading data?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following is a simple repro case using the loopback mode, which always gets stuck after the overrun.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class="c++" name="code"&gt;#include "derivative.h"&amp;nbsp; // Transmit a character and busy-wait for it to get through static void transmit(char data) { &amp;nbsp;&amp;nbsp;&amp;nbsp; SCID = data; &amp;nbsp;&amp;nbsp;&amp;nbsp; data = 0; &amp;nbsp;&amp;nbsp;&amp;nbsp; do { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; __RESET_WATCHDOG(); &amp;nbsp;&amp;nbsp;&amp;nbsp; } while(++data); }&amp;nbsp; void main(void) { &amp;nbsp;&amp;nbsp;&amp;nbsp; char overrun = 10;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // Initialize the UART in loopback mode &amp;nbsp;&amp;nbsp;&amp;nbsp; SCIBD = 1; &amp;nbsp;&amp;nbsp;&amp;nbsp; SCIC1_LOOPS = 1; &amp;nbsp;&amp;nbsp;&amp;nbsp; SCIC2 = SCIC2_RE_MASK | SCIC2_TE_MASK; &amp;nbsp;&amp;nbsp;&amp;nbsp; (void) SCIS1; &amp;nbsp;&amp;nbsp;&amp;nbsp; (void) SCID;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // Keep transmitting character to ourself &amp;nbsp;&amp;nbsp;&amp;nbsp; for(;;) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; transmit(overrun);&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Received anything? &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(SCIS1_RDRF) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Force an intermittent buffer overflow. Imagine the next character &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // arriving in the middle of a delayed interrupt &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(!--overrun) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; transmit(overrun);&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Actually fetch the character &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (void) SCID; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &amp;nbsp;&amp;nbsp;&amp;nbsp; } }&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Mar 2013 19:05:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Overrun-detection-needed-for-reliable-SCI-reception/m-p/234439#M19449</guid>
      <dc:creator>implicit</dc:creator>
      <dc:date>2013-03-21T19:05:28Z</dc:date>
    </item>
    <item>
      <title>Re: Overrun detection needed for reliable SCI reception?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Overrun-detection-needed-for-reliable-SCI-reception/m-p/234440#M19450</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Johan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is likely that the overrun error has already occurred by the time that the ISR code executes.&amp;nbsp; An overrun occurs when a new character has been received by the SCI, but the previous character within the receive buffer has not yet been read, with the new data being lost.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The RDRF flag does not actually clear until &lt;EM&gt;both&lt;/EM&gt; the SCIS1 register has been read, followed by the SCID register.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One possible cause of the overrun is that the commencement of the SCI receive ISR is delayed by the execution of another ISR, possibly one of the TPM interrupts, which have higher priority in a pending interrupt situation.&amp;nbsp; There may be a number of reasons for this -&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;The SCI baud rate is too high for the bus clock frequency in use.&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;The execution cycles&amp;nbsp; of the SCI receive ISR is too long.&amp;nbsp; Any lengthy manipulation of the received data should be done from outside the ISR.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;The execution cycles of one or more of the other enabled interrupts is too long. &lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;BR /&gt;To ensure that overrun does not occur, 10 times the baud period needs to be greater than the execution cycles of the SCI receive ISR itself, plus the worst case execution cycles of the longest "other" ISR.&amp;nbsp; Assuming this is the problem, it demonstrates the need to always keep all ISR code as short as possible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The state of the OR flag, as well as the RDRF flag, may be tested within the ISR.&amp;nbsp; Whenever an overrun error is detected, you will probably need to flag that an error response needs to be returned, so the the original data can be re-sent by the remote end.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do not know the reason for the overrun not appearing during FCS, assuming bus frequency and baud rate is the same in both instances.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Mar 2013 07:03:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Overrun-detection-needed-for-reliable-SCI-reception/m-p/234440#M19450</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2013-03-22T07:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: Overrun detection needed for reliable SCI reception?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Overrun-detection-needed-for-reliable-SCI-reception/m-p/234441#M19451</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Mac and thank you for taking a look at my ramblings however I think you misunderstood my problem. An occasional overrun during communication is quite tolerable, we use checksumming and a reliable delivery scheme to insure to that data will eventually get through intact.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My real issue is that the overrun happening to arriving between the polling of SCIS1 and reading of SCID appears to leave the receive buffer full without RDRF set (and OR raised.)&lt;/P&gt;&lt;P&gt;The effect being that no further incoming data will *ever* be processed, since RDRF cannot be set until the buffer gets flushed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can work around the issue easily enough by implementing an overrun interrupt which manually flushes the buffer, but it seems to me that this behaviour leaves the receiver vulnerable to a very subtle and insidious race condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This leaves me working whether I am reading data in the wrong way, whether this might be silicon bug on the 9S08 SCI, or if I am labouring under some other misapprehension.&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Mar 2013 07:54:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Overrun-detection-needed-for-reliable-SCI-reception/m-p/234441#M19451</guid>
      <dc:creator>implicit</dc:creator>
      <dc:date>2013-03-22T07:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: Overrun detection needed for reliable SCI reception?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Overrun-detection-needed-for-reliable-SCI-reception/m-p/234442#M19452</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Johan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you should have SCI error interrupt handler to handle SCI overruns. I think this will solve your issue.&lt;/P&gt;&lt;P&gt;BTW there's a bug in your transmit routine. You need to read status register before writing SCID.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Mar 2013 08:55:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Overrun-detection-needed-for-reliable-SCI-reception/m-p/234442#M19452</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2013-03-22T08:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: Overrun detection needed for reliable SCI reception?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Overrun-detection-needed-for-reliable-SCI-reception/m-p/234443#M19453</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Johan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes, it would be possible for an overrun condition to occasionally occur after reading SCIS1 register, but prior to reading the SCID register, due to the arrival of the next character.&amp;nbsp; I would expect that this should not occur very frequently with only a few cycles between the two processes (I assume this is actually the case).&amp;nbsp; Here, I would assume that the RDRF flag would be cleared, but the OR flag would remain set.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Possible solution 1:&lt;/P&gt;&lt;P&gt;Immediately after reading SCID, read SCIS1 register again.&amp;nbsp; If any error flag is set, do another dummy read of SCID.&lt;/P&gt;&lt;P&gt;Possible solution 2:&lt;/P&gt;&lt;P&gt;Enable overrun interrupt for SCI error interrupt.&amp;nbsp; The minimum ISR code should read SCIS1 and then read SCID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Of course, this ignores the reasons why the overruns are occurring in the first instance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Mar 2013 09:22:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Overrun-detection-needed-for-reliable-SCI-reception/m-p/234443#M19453</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2013-03-22T09:22:40Z</dc:date>
    </item>
    <item>
      <title>Re: Overrun detection needed for reliable SCI reception?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Overrun-detection-needed-for-reliable-SCI-reception/m-p/234444#M19454</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, handling overflow interrupts seems to work, thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As for the transmit routine I'm explicitly not reading the status register in that example to be able to demonstrate the issue through the loopback interface. In the actual application the data is sent by a different host.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Mar 2013 10:01:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Overrun-detection-needed-for-reliable-SCI-reception/m-p/234444#M19454</guid>
      <dc:creator>implicit</dc:creator>
      <dc:date>2013-03-22T10:01:26Z</dc:date>
    </item>
    <item>
      <title>Re: Overrun detection needed for reliable SCI reception?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Overrun-detection-needed-for-reliable-SCI-reception/m-p/234445#M19455</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Indeed the window of opportunity is very short and the problem occurs exceedingly seldom. In this particular application it would occasionally lock up a node every few days when the receiver interrupt happened to be sufficiently delayed and the stars were in alignment.&lt;/P&gt;&lt;P&gt;After that the operator would need to manually reset the system to recover.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I believe the actual cause of the delays were a FLASH write temporarily disabling interrupts, though it may have been something else. Obviously frequent overruns are not acceptable and I'll certainly strive to avoid them, but guaranteeing minimum interrupt latencies in all possible paths of the application would be an awful lot of work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Oh well, time to go back and add overrun handling to various old applications. Thanks for confirming this behaviour!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Mar 2013 10:13:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Overrun-detection-needed-for-reliable-SCI-reception/m-p/234445#M19455</guid>
      <dc:creator>implicit</dc:creator>
      <dc:date>2013-03-22T10:13:21Z</dc:date>
    </item>
    <item>
      <title>Re: Overrun detection needed for reliable SCI reception?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Overrun-detection-needed-for-reliable-SCI-reception/m-p/234446#M19456</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please note that (void)SCIS1; doesn't necessarily produce a read of the register, even if SCIS1 has been declared as volatile. Whether a compiler is forced to generate such code or not has been debated, no matter what the standard says there are plenty of compilers that will not generate any code when encountering that line. I would disassemble to code to ensure that an actual read takes place.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A better, portable way is to do:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;volatile uint8_t scis1_dummy;&lt;/P&gt;&lt;P&gt;dummy = SCIS1;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Mar 2013 14:21:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Overrun-detection-needed-for-reliable-SCI-reception/m-p/234446#M19456</guid>
      <dc:creator>Lundin</dc:creator>
      <dc:date>2013-03-22T14:21:26Z</dc:date>
    </item>
    <item>
      <title>Re: Overrun detection needed for reliable SCI reception?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Overrun-detection-needed-for-reliable-SCI-reception/m-p/234447#M19457</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the heads-up.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've double-checked the compiler output and CodeWarrior does indeed generate loads for these statements. Unfortunately storing the result to a volatile dummy variable generates an additional write of the result to the stack, increasing the window of opportunity for this particular issue by a couple of cycles. I don't suppose there's a more efficient way of reliably forcing the desired behaviour?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To be honest I had rather thought this was guaranteed by the standard and universally supported but after my adventures with Microchip's MCC18 I should have learned never to take anything for granted.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Mar 2013 14:47:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Overrun-detection-needed-for-reliable-SCI-reception/m-p/234447#M19457</guid>
      <dc:creator>implicit</dc:creator>
      <dc:date>2013-03-22T14:47:00Z</dc:date>
    </item>
    <item>
      <title>Re: Overrun detection needed for reliable SCI reception?</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Overrun-detection-needed-for-reliable-SCI-reception/m-p/234448#M19458</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Johan,&lt;/P&gt;&lt;BLOCKQUOTE&gt;
&lt;P&gt;Johan Forslöf wrote:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;I've double-checked the compiler output and CodeWarrior does indeed generate loads for these statements. Unfortunately storing the result to a volatile dummy variable generates an additional write of the result to the stack, increasing the window of opportunity for this particular issue by a couple of cycles. I don't suppose there's a more efficient way of reliably forcing the desired behaviour?&lt;/P&gt;
 &lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have never had a problem with the CW compiler providing a read for a volatile register.&amp;nbsp; However, an alternative method would be to provide macros that use HLI assembler to generate the read process, without the overhead of creating, and writing to a variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;#define&amp;nbsp; SCIS1_read&amp;nbsp; __asm lda SCIS1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;#define&amp;nbsp; SCID_read&amp;nbsp;&amp;nbsp; __asm lda SCID&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 24 Mar 2013 14:45:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Overrun-detection-needed-for-reliable-SCI-reception/m-p/234448#M19458</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2013-03-24T14:45:11Z</dc:date>
    </item>
  </channel>
</rss>

