<?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: problem with programming in C in ColdFire/68K Microcontrollers and Processors</title>
    <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/problem-with-programming-in-C/m-p/168968#M6084</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not 100% sure if this is what you are asking, but you can use wide character strings in Code Warrior, like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;unsigned short *xxx = L"hello world\n";&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That is a bit different than what you packed up, because of endian issues --&amp;nbsp;you'd then have to byteswap each short if you wanted the low byte first, followed by the 0, prior to sending the data out of the MCU.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are also all of the wide character manipulation functions, like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT face="Courier" size="1"&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;P&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT size="2"&gt;#include &amp;lt;wchar.h&amp;gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT size="2"&gt;int wcscmp(const wchar_t * str1, const wchar_t * str2);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-- Rich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 03 Apr 2009 03:54:29 GMT</pubDate>
    <dc:creator>RichTestardi</dc:creator>
    <dc:date>2009-04-03T03:54:29Z</dc:date>
    <item>
      <title>problem with programming in C</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/problem-with-programming-in-C/m-p/168966#M6082</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The bord that I use is a demo52233DEMO and I'm using the coldfire lite stack =&amp;gt; TCP_client&lt;/P&gt;&lt;P&gt;and I want to send unicode-encoded textual messages (packets) to a tcp server. I can already do that, but the methode I use is far to mutch work. Also I want to detect several unicode messages how can I do that? And my final question is how can I send a fin pakket when I reset the board? This is an example of the methode that I use for sending stuf.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; length = m_recv( emg_tcp_communication_socket, (char *)buffer, RX_BUFFER_SIZE );&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //--------alive ---------&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; len = 54;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_alive[0]= 'a';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_alive[2]= 'l';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_alive[4]= 'i';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_alive[6]= 'v';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_alive[8]= 'e';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_alive[10]= ':';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_alive[12]= 'S';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_alive[14]= 't';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_alive[16]= 'i';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_alive[18]= 'l';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_alive[20]= 'l';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_alive[22]= ' ';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_alive[24]= 'a';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_alive[26]= 'l';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_alive[28]= 'i';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_alive[30]= 'v';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_alive[32]= 'e';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_alive[34]= ',';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_alive[36]= ' ';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_alive[38]= 's';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_alive[40]= 'e';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_alive[42]= 'r';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_alive[44]= 'v';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_alive[46]= 'e';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_alive[48]= 'r';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_alive[50]= '?';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data_alive[52]= '\01';&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //----------------------&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (void)m_send( emg_tcp_communication_socket, (char *)data_alive, len );&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;greets jonas&lt;/P&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by jonasb on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-04-02&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;07:52 AM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Apr 2009 13:50:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/problem-with-programming-in-C/m-p/168966#M6082</guid>
      <dc:creator>jonasb</dc:creator>
      <dc:date>2009-04-02T13:50:21Z</dc:date>
    </item>
    <item>
      <title>Re: problem with programming in C</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/problem-with-programming-in-C/m-p/168967#M6083</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not shure to understand your issue.&amp;nbsp; It seems you're looking for a better way to extract rxed buffer, and to fill tx buffer.&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not familiar with the unicode message, could you explain it, and what is in the odd indexes of your buffer?&amp;nbsp; Is it '\0' marking the end of a string?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FB&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Apr 2009 02:59:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/problem-with-programming-in-C/m-p/168967#M6083</guid>
      <dc:creator>francois_boucha</dc:creator>
      <dc:date>2009-04-03T02:59:00Z</dc:date>
    </item>
    <item>
      <title>Re: problem with programming in C</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/problem-with-programming-in-C/m-p/168968#M6084</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm not 100% sure if this is what you are asking, but you can use wide character strings in Code Warrior, like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;unsigned short *xxx = L"hello world\n";&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That is a bit different than what you packed up, because of endian issues --&amp;nbsp;you'd then have to byteswap each short if you wanted the low byte first, followed by the 0, prior to sending the data out of the MCU.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are also all of the wide character manipulation functions, like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT face="Courier" size="1"&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;P&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT size="2"&gt;#include &amp;lt;wchar.h&amp;gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT face="Courier" size="1"&gt;&lt;FONT size="2"&gt;int wcscmp(const wchar_t * str1, const wchar_t * str2);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-- Rich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Apr 2009 03:54:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/problem-with-programming-in-C/m-p/168968#M6084</guid>
      <dc:creator>RichTestardi</dc:creator>
      <dc:date>2009-04-03T03:54:29Z</dc:date>
    </item>
    <item>
      <title>Re: problem with programming in C</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/problem-with-programming-in-C/m-p/168969#M6085</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I want fill tx buffer. But the only way that I know to do that is to this like discribed above here. The unicode looks like this in the pakket [.a.l.i.v.e.:.s.t.i.l.l. .a.l.l.i.v.e.,. .s.e.r.v.e.r.?./01]. This is the message that the client has to send to the tcp-server.&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Apr 2009 13:15:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/problem-with-programming-in-C/m-p/168969#M6085</guid>
      <dc:creator>jonasb</dc:creator>
      <dc:date>2009-04-03T13:15:42Z</dc:date>
    </item>
    <item>
      <title>Re: problem with programming in C</title>
      <link>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/problem-with-programming-in-C/m-p/168970#M6086</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; unicode looks like this in the pakket &lt;STRONG&gt;[.a.l.i.v.e.:.s.t.i.l.l. .a.l.l.i.v.e.,. .s.e.r.v.e.r.?./01].&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe I completely misunderstand you, but if you put the &lt;STRONG&gt;"L"&lt;/STRONG&gt; in front of a character string, the compiler will allocate 16 bits (a wide character) for each character, rather than 8 bits (a normal character).&amp;nbsp; This looks a lot like the ASCII portion of UCS-2 or UTF-16 unicode (but nothing like UTF-8).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In your original post, you showed the characters in "little endian" format, with the 'a' before its corresponding 0; in the example above, you show them in "big endian" format, with the 0 (presumably the '.') before its corresponding 'a'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you define:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;STRONG&gt;unsigned short buffer = L"alive:still allive, server?\01";&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You'll have a buffer with 16 bits per character, with the characters packed into the second byte of the 16 bits (i.e., big endian format, because ColdFire is big endian), &lt;STRONG&gt;just like in the example above&lt;/STRONG&gt; (I assume you wanted an SOH with the \01).&amp;nbsp; And the wide character functions I mentioned earlier are meant to manipulate these types of strings, just like the normal string functions manipulate 8 bit character strings.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you need them in little-endian format, you just need to loop thru the shorts in the buffer and byteswap them -- byteswapping is a way of life when sending data off-board, since different CPUs have different endiannesses, so typically you'll have one routine that will do that for you just before sending the data out (or after receiving it in) -- remember, you only want to byteswap multi-byte quantities, and you have to know the size of the quantity to do it (in this case, you're byteswapping 16 bit quantities, so it is really easy).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Apr 2009 19:59:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/ColdFire-68K-Microcontrollers/problem-with-programming-in-C/m-p/168970#M6086</guid>
      <dc:creator>RichTestardi</dc:creator>
      <dc:date>2009-04-03T19:59:25Z</dc:date>
    </item>
  </channel>
</rss>

