<?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 Re: Re: K20 UART with 2 stop bit or parity in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K20-UART-with-2-stop-bit-or-parity/m-p/353317#M17548</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Massimiliano&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note further that the uTasker project has this "true 2 bit stop mode" integrated into its UART driver: &lt;A href="http://www.utasker.com/docs/uTasker/uTaskerUART.PDF" title="http://www.utasker.com/docs/uTasker/uTaskerUART.PDF"&gt;http://www.utasker.com/docs/uTasker/uTaskerUART.PDF&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2-bit stop mode is in fact quite rare but in case of it being required for a serious reason I have attached a binary showing it in 'live' operation. I don't know which K20 board you have so I made this for the FRDM_K22F board (which seems quite popular at the moment).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is a message sent out on the debug UART (the one connected to the OpenSDA virtual COM port) every few seconds which can be measured with an oscilloscope on R66. It can be seen that the stop bit at the end of the first byte (easy to measure) and all bytes in the message (send as a block of data) has a single Baud period.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is also a command line menu on the UART (virtualCOM connection) and in the "Configure serial interface" menu (2) there is a command to set the number of stop bits.&lt;/P&gt;&lt;P&gt;"set_stop 2" will change the UART mode to 2 stop bits&lt;/P&gt;&lt;P&gt;"set_stop 1" will change it to 1 stop bit&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is possible to watch the data being sent and see that in 2 stop bit mode the block of bytes always has a perfect 2 stop bit between each byte. In 1 stop bit mode it is 1.&lt;/P&gt;&lt;P&gt;This shows that the "workaround" described allows true 2 stop bit operation to be achieved.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 20 Nov 2014 04:36:22 GMT</pubDate>
    <dc:creator>mjbcswitzerland</dc:creator>
    <dc:date>2014-11-20T04:36:22Z</dc:date>
    <item>
      <title>K20 UART with 2 stop bit or parity</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K20-UART-with-2-stop-bit-or-parity/m-p/353315#M17546</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi to all&lt;/P&gt;&lt;P&gt;I'm working on a K20 uP&lt;/P&gt;&lt;P&gt;I want to use 2 stop bit but I have a problem!&lt;/P&gt;&lt;P&gt;Obsverving &lt;/P&gt;&lt;P&gt;Sub Family reference Manuale K20 R6 Nov 2011 I see on page 1932 - 1395 that the UART do not support 2 stop bit! &lt;/P&gt;&lt;P&gt;It seems very strange so I'm asking how to configure uP to use 2 stop bit!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another configuration-problem: How to use Parity with 8 data bits?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many Thanks,&lt;/P&gt;&lt;P&gt;Massimiliano&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Nov 2014 08:51:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K20-UART-with-2-stop-bit-or-parity/m-p/353315#M17546</guid>
      <dc:creator>holyhope</dc:creator>
      <dc:date>2014-11-19T08:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: K20 UART with 2 stop bit or parity</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K20-UART-with-2-stop-bit-or-parity/m-p/353316#M17547</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Massimiliano&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you configure for 1 stop bit (which you have to) it won't have any implecations for your receiver - should the peer be configured for 2 stop bits you will already completely receive each character after 1 stop bit and the second will simply be an additional 1 bit period pause (IDLE),&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The peer could however have problems when configured for 2 stop bits and you send only 1. This can happen when you send two characters "immediately" after another and the start bit of the second character is sent after just 1 stop bit time, while the peer is still waiting for the second stop bit to arrive. In the worst case the peer's receiver will see your start bit as an invalid second stop bit and then also miss the start bit and hence the next character will be corrupted. However the peer, while working in 2 stop bit mode may also simply accept that there was a fast new start bit and so not have any problems. Therefore what actually happens is undefined.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To avoid the potential problem the only option is to insert a slight pause between each transmitted character or at least 1 bit time. DMA transmission is not possible becaue it will send multiple bytes without any pauses, but when interrupt driven the "transmit complete flag" interrupt can be used instead of the "transmit buffer empty" interrupt. The interesting thing about this interrupt is that is that immediately writing the next character when it occurs inserts a &lt;EM&gt;single bit idle period&lt;/EM&gt; onto the UART Tx, which is in fact exactly what you need. The reason for this is that the UART works with a bit clock equal to the BAUD rate (rather than being purely asynchronous) and exactly when the "transmit complete flag" interrupt fires the next bit is clocked out - since there is no data byte in the DATA register at that instance an idle bit is inserted. At the next bit time you will probably have already written the next Tx byte into the DATA register and so the UART will then insert the start bit of the next character.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This timing is probably conincidence but it does in fact allow true 2 stop bit transmission to be realised with an interrupt driven UART driver.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;How to use Parity with 8 data bits?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For 7 bit mode with parity write &lt;STRONG&gt;UART_C1&lt;/STRONG&gt; with &lt;STRONG&gt;PE&lt;/STRONG&gt; and optionally &lt;STRONG&gt;PT&lt;/STRONG&gt; (7 bit even or odd parity)&lt;/P&gt;&lt;P&gt;For 8 bit mode with parity write &lt;STRONG&gt;UART_C1&lt;/STRONG&gt; with &lt;STRONG style="text-decoration: underline;"&gt;M&lt;/STRONG&gt; and &lt;STRONG&gt;PE&lt;/STRONG&gt; and optionally &lt;STRONG&gt;PT&lt;/STRONG&gt; (8 bit even or odd parity)&lt;/P&gt;&lt;P&gt;Therefore use the M bit to control the data length you want&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P.S. Strangely, the UARTs 1 and higher in the KL parts do support 2 stop bit mode, as does the LPUART in the KL03.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.utasker.com/kinetis.html" title="http://www.utasker.com/kinetis.html"&gt;http://www.utasker.com/kinetis.html&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Nov 2014 18:44:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K20-UART-with-2-stop-bit-or-parity/m-p/353316#M17547</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2014-11-19T18:44:21Z</dc:date>
    </item>
    <item>
      <title>Re: Re: K20 UART with 2 stop bit or parity</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K20-UART-with-2-stop-bit-or-parity/m-p/353317#M17548</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Massimiliano&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note further that the uTasker project has this "true 2 bit stop mode" integrated into its UART driver: &lt;A href="http://www.utasker.com/docs/uTasker/uTaskerUART.PDF" title="http://www.utasker.com/docs/uTasker/uTaskerUART.PDF"&gt;http://www.utasker.com/docs/uTasker/uTaskerUART.PDF&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2-bit stop mode is in fact quite rare but in case of it being required for a serious reason I have attached a binary showing it in 'live' operation. I don't know which K20 board you have so I made this for the FRDM_K22F board (which seems quite popular at the moment).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is a message sent out on the debug UART (the one connected to the OpenSDA virtual COM port) every few seconds which can be measured with an oscilloscope on R66. It can be seen that the stop bit at the end of the first byte (easy to measure) and all bytes in the message (send as a block of data) has a single Baud period.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is also a command line menu on the UART (virtualCOM connection) and in the "Configure serial interface" menu (2) there is a command to set the number of stop bits.&lt;/P&gt;&lt;P&gt;"set_stop 2" will change the UART mode to 2 stop bits&lt;/P&gt;&lt;P&gt;"set_stop 1" will change it to 1 stop bit&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is possible to watch the data being sent and see that in 2 stop bit mode the block of bytes always has a perfect 2 stop bit between each byte. In 1 stop bit mode it is 1.&lt;/P&gt;&lt;P&gt;This shows that the "workaround" described allows true 2 stop bit operation to be achieved.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Nov 2014 04:36:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K20-UART-with-2-stop-bit-or-parity/m-p/353317#M17548</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2014-11-20T04:36:22Z</dc:date>
    </item>
    <item>
      <title>Re: K20 UART with 2 stop bit or parity</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/K20-UART-with-2-stop-bit-or-parity/m-p/353318#M17549</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Many thanks for your answer, it is what I need to know &lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Nov 2014 15:33:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/K20-UART-with-2-stop-bit-or-parity/m-p/353318#M17549</guid>
      <dc:creator>holyhope</dc:creator>
      <dc:date>2014-11-20T15:33:11Z</dc:date>
    </item>
  </channel>
</rss>

