<?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: Serial / USB not sending bytes with MSB on in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Serial-USB-not-sending-bytes-with-MSB-on/m-p/665787#M40918</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Robert&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Change&lt;/P&gt;&lt;PRE&gt;void putchar(char ch)&lt;/PRE&gt;&lt;P&gt;to&lt;/P&gt;&lt;PRE&gt;void putchar(&lt;STRONG&gt;unsigned&lt;/STRONG&gt; char ch)&lt;/PRE&gt;&lt;P&gt;and it will 'magically' start working.&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;P.S. I think that there was a thread about 4 weeks ago where the same mistake was made, including explanation &lt;SPAN class="lia-unicode-emoji" title=":winking_face:"&gt;&lt;LI-EMOJI id="lia_winking-face" title=":winking_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 04 May 2017 15:13:24 GMT</pubDate>
    <dc:creator>mjbcswitzerland</dc:creator>
    <dc:date>2017-05-04T15:13:24Z</dc:date>
    <item>
      <title>Serial / USB not sending bytes with MSB on</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Serial-USB-not-sending-bytes-with-MSB-on/m-p/665786#M40917</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a FRDM-KL27Z dev board communicating with my Mac OSX via the OpenSDA USB port. &amp;nbsp;&lt;/P&gt;&lt;P&gt;It appears that if I write a char to the LPUART with&amp;nbsp;the MSB turned on (i.e. 0x80 - 0xff), the serial line goes idle for one byte period instead of transmitting the character, so if I send the pattern:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; putchar(0x55);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; putchar(0xa5);&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; putchar(0x5a);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... on the 'scope (J1-04, aka TX), I see 0x55 followed 10 bit periods of 'mark'&amp;nbsp;followed by 0x5a .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any idea what's going on?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2 id="toc-hId-1764794816"&gt;Some details:&lt;/H2&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm enabling &lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;LPUART0&lt;/SPAN&gt; like this:&lt;/P&gt;&lt;PRE&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp; &lt;/SPAN&gt;lpuart_config_t&lt;SPAN class=""&gt; config;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp; &lt;/SPAN&gt;LPUART_GetDefaultConfig(&amp;amp;config);&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp; &lt;/SPAN&gt;config.&lt;SPAN class=""&gt;baudRate_Bps&lt;/SPAN&gt; = 9600;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp; &lt;/SPAN&gt;config.&lt;SPAN class=""&gt;enableTx&lt;/SPAN&gt; = true;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp; &lt;/SPAN&gt;config.&lt;SPAN class=""&gt;enableRx&lt;/SPAN&gt; = true;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp; CLOCK_SetLpuart0Clock(0x03);&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp; uint32_t uartClkSrcFreq = CLOCK_GetFreq(kCLOCK_McgInternalRefClk);&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp; LPUART_Init(LPUART0, &amp;amp;config, uartClkSrcFreq);&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;And my &lt;SPAN style="font-family: terminal, monaco, monospace;"&gt;putchar()&lt;/SPAN&gt; routine looks like this:&lt;/P&gt;&lt;PRE&gt;void putchar(char ch) {
&lt;P class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class=""&gt;while&lt;/SPAN&gt; (!(LPUART0-&amp;gt;&lt;SPAN class=""&gt;STAT&lt;/SPAN&gt; &amp;amp; LPUART_STAT_TDRE_MASK)) {&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;// busy wait until TX buffer ready&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp; &lt;/SPAN&gt;}&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&amp;nbsp; &lt;SPAN&gt;LPUART0&lt;/SPAN&gt;&lt;/SPAN&gt;-&amp;gt;&lt;SPAN class=""&gt;DATA&lt;/SPAN&gt; = ch;&lt;/P&gt;&lt;P class=""&gt;}&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 May 2017 14:35:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Serial-USB-not-sending-bytes-with-MSB-on/m-p/665786#M40917</guid>
      <dc:creator>robertpoor</dc:creator>
      <dc:date>2017-05-04T14:35:31Z</dc:date>
    </item>
    <item>
      <title>Re: Serial / USB not sending bytes with MSB on</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Serial-USB-not-sending-bytes-with-MSB-on/m-p/665787#M40918</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Robert&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Change&lt;/P&gt;&lt;PRE&gt;void putchar(char ch)&lt;/PRE&gt;&lt;P&gt;to&lt;/P&gt;&lt;PRE&gt;void putchar(&lt;STRONG&gt;unsigned&lt;/STRONG&gt; char ch)&lt;/PRE&gt;&lt;P&gt;and it will 'magically' start working.&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;P.S. I think that there was a thread about 4 weeks ago where the same mistake was made, including explanation &lt;SPAN class="lia-unicode-emoji" title=":winking_face:"&gt;&lt;LI-EMOJI id="lia_winking-face" title=":winking_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 May 2017 15:13:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Serial-USB-not-sending-bytes-with-MSB-on/m-p/665787#M40918</guid>
      <dc:creator>mjbcswitzerland</dc:creator>
      <dc:date>2017-05-04T15:13:24Z</dc:date>
    </item>
    <item>
      <title>Re: Serial / USB not sending bytes with MSB on</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Serial-USB-not-sending-bytes-with-MSB-on/m-p/665788#M40919</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hah! &amp;nbsp;I just figured it out independently. &amp;nbsp;:smileyhappy:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By declaring it a&amp;nbsp;char (rather than uint8_t), a byte with the MSB set gets sign extended to the full 32 bit LPUART0-&amp;gt;DATA register. &amp;nbsp;Bit 13 in the DATA register is FRETSC, or Frame Error / Transmit Special Character. &amp;nbsp;And from the docs: "For writes, indicates a break or idle character is to be transmitted instead of the contents in DATA[T9:T0]. T9 is used to indicate a break character when 0 and a idle character when 1, he contents of DATA[T8:T0] should be zero." &amp;nbsp;Which is exactly what I'm seeing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, yep, using a uint8_t will fix all that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 May 2017 15:40:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Serial-USB-not-sending-bytes-with-MSB-on/m-p/665788#M40919</guid>
      <dc:creator>robertpoor</dc:creator>
      <dc:date>2017-05-04T15:40:57Z</dc:date>
    </item>
  </channel>
</rss>

