<?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: char to int ASCII hex in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/char-to-int-ASCII-hex/m-p/162205#M4552</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;It is very easy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 15 Dec 2009 18:41:48 GMT</pubDate>
    <dc:creator>roberto_m</dc:creator>
    <dc:date>2009-12-15T18:41:48Z</dc:date>
    <item>
      <title>char to int ASCII hex</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/char-to-int-ASCII-hex/m-p/162198#M4545</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello, I would like ask. I need convert e.g. char "AE" to unsigned short int 0x4145? do any body pleas know how I can convert this? Thank you very much.&lt;/SPAN&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by Seitec on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-03-13&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;10:53 PM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Mar 2009 05:52:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/char-to-int-ASCII-hex/m-p/162198#M4545</guid>
      <dc:creator>Seitec</dc:creator>
      <dc:date>2009-03-14T05:52:33Z</dc:date>
    </item>
    <item>
      <title>Re: char to int ASCII hex</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/char-to-int-ASCII-hex/m-p/162199#M4546</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;Assuming big endian data format, simply create a union between a char array and an unsigned short variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;typedef union {&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; char a[3];&amp;nbsp; // Allow for null termination&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned short b;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;} ascseq;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;ascseq val;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Define variable&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To load data to the array -&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; val.a[] = "AE";&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To read the equivalent integer value, use &lt;FONT face="courier new,courier"&gt;val.b&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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>Sat, 14 Mar 2009 07:19:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/char-to-int-ASCII-hex/m-p/162199#M4546</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2009-03-14T07:19:45Z</dc:date>
    </item>
    <item>
      <title>Re: char to int ASCII hex</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/char-to-int-ASCII-hex/m-p/162200#M4547</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp; val.a[] = "AE";&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;I think you meant here&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp; strcpy(val.a, "AE");&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;or&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&amp;nbsp; memcpy(val.a, "AE", 2);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Mar 2009 15:07:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/char-to-int-ASCII-hex/m-p/162200#M4547</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2009-03-14T15:07:17Z</dc:date>
    </item>
    <item>
      <title>Re: char to int ASCII hex</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/char-to-int-ASCII-hex/m-p/162201#M4548</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Thank you very much.Great thank you &lt;IMG alt=":smileyhappy:" class="emoticon emoticon-smileyhappy" id="smileyhappy" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-happy.gif" title="Smiley Happy" /&gt;.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Mar 2009 15:29:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/char-to-int-ASCII-hex/m-p/162201#M4548</guid>
      <dc:creator>Seitec</dc:creator>
      <dc:date>2009-03-14T15:29:49Z</dc:date>
    </item>
    <item>
      <title>Re: char to int ASCII hex</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/char-to-int-ASCII-hex/m-p/162202#M4549</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry about that. I was somewhat confused with the initialisation process allowed within the definition of an array variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another alternative to the use of the copy functions might be to load each of the two array elements separately -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;val.a[0] = 'A';&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;val.a[1] = 'E';&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;or perhaps create a function -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;unsigned short getval( char *s)&lt;BR /&gt;{&lt;BR /&gt;ascseq temp;&lt;BR /&gt;&lt;BR /&gt;temp.a[0] = s[0];&lt;BR /&gt;temp.a[1] = s[1];&lt;BR /&gt;return temp.b;&lt;BR /&gt;}&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;with the following usage -&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;unsigned short i;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;i = getval( "AE" );&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by bigmac on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-03-15&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;05:04 AM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 15 Mar 2009 00:57:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/char-to-int-ASCII-hex/m-p/162202#M4549</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2009-03-15T00:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: char to int ASCII hex</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/char-to-int-ASCII-hex/m-p/162203#M4550</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And how can I convert a counter (stored in an unsigned char)&amp;nbsp; to a string?&lt;/P&gt;&lt;P&gt;I mean:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;0xFF &amp;gt;&amp;gt; 255 &amp;gt;&amp;gt; 32:35:35 (ASCII values)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Dec 2009 21:26:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/char-to-int-ASCII-hex/m-p/162203#M4550</guid>
      <dc:creator>roberto_m</dc:creator>
      <dc:date>2009-12-14T21:26:46Z</dc:date>
    </item>
    <item>
      <title>Re: char to int ASCII hex</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/char-to-int-ASCII-hex/m-p/162204#M4551</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check out &lt;A href="http://www.freescale.com/webapp/sps/utils/SingleFaq.jsp?FAQ-27705.xml" rel="nofollow" target="_self"&gt;FAQ-27705&lt;/A&gt; for source code that converts a binary value to a text string.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;---Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Dec 2009 22:03:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/char-to-int-ASCII-hex/m-p/162204#M4551</guid>
      <dc:creator>J2MEJediMaster</dc:creator>
      <dc:date>2009-12-14T22:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: char to int ASCII hex</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/char-to-int-ASCII-hex/m-p/162205#M4552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;It is very easy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Dec 2009 18:41:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/char-to-int-ASCII-hex/m-p/162205#M4552</guid>
      <dc:creator>roberto_m</dc:creator>
      <dc:date>2009-12-15T18:41:48Z</dc:date>
    </item>
  </channel>
</rss>

