<?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: Read and Write Bytes in a Word in 8-bit Microcontrollers</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Read-and-Write-Bytes-in-a-Word/m-p/128511#M1713</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Thank you Lupin.&lt;BR /&gt;&lt;BR /&gt;I knew that redefining the Word type was a solution.&lt;BR /&gt;&lt;BR /&gt;I would like to avoid to do so and stick to the word type provided in Metrowerks.&lt;BR /&gt;&lt;BR /&gt;I found no trace of the definition of that word type in the Project File.&lt;BR /&gt;&lt;BR /&gt;Anybody, an other idea ?&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Mar 2006 22:36:42 GMT</pubDate>
    <dc:creator>DEMO908AP64</dc:creator>
    <dc:date>2006-03-10T22:36:42Z</dc:date>
    <item>
      <title>Read and Write Bytes in a Word</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Read-and-Write-Bytes-in-a-Word/m-p/128509#M1711</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Unsuccessfully, I tried with .l and .h ...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any idea ?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Mar 2006 09:14:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Read-and-Write-Bytes-in-a-Word/m-p/128509#M1711</guid>
      <dc:creator>DEMO908AP64</dc:creator>
      <dc:date>2006-03-10T09:14:10Z</dc:date>
    </item>
    <item>
      <title>Re: Read and Write Bytes in a Word</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Read-and-Write-Bytes-in-a-Word/m-p/128510#M1712</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Try this:&lt;BR /&gt;union {&lt;BR /&gt;struct {&lt;BR /&gt;byte hi_;&lt;BR /&gt;byte lo_;&lt;BR /&gt;}part_;&lt;BR /&gt;word sum_;&lt;BR /&gt;}ful_;&lt;BR /&gt;&lt;BR /&gt;#define hi_byte ful_.part_.hi_&lt;BR /&gt;#define lo_byte ful_.part_.lo_&lt;BR /&gt;#define full_word ful_.sum_&lt;BR /&gt;&lt;BR /&gt;hi_byte=55;&lt;BR /&gt;lo_byte=22;&lt;BR /&gt;if(full_word&amp;gt;3200)&lt;BR /&gt;&lt;BR /&gt;Is it OK?&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Mar 2006 10:04:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Read-and-Write-Bytes-in-a-Word/m-p/128510#M1712</guid>
      <dc:creator>lupin</dc:creator>
      <dc:date>2006-03-10T10:04:19Z</dc:date>
    </item>
    <item>
      <title>Re: Read and Write Bytes in a Word</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Read-and-Write-Bytes-in-a-Word/m-p/128511#M1713</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Thank you Lupin.&lt;BR /&gt;&lt;BR /&gt;I knew that redefining the Word type was a solution.&lt;BR /&gt;&lt;BR /&gt;I would like to avoid to do so and stick to the word type provided in Metrowerks.&lt;BR /&gt;&lt;BR /&gt;I found no trace of the definition of that word type in the Project File.&lt;BR /&gt;&lt;BR /&gt;Anybody, an other idea ?&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Mar 2006 22:36:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Read-and-Write-Bytes-in-a-Word/m-p/128511#M1713</guid>
      <dc:creator>DEMO908AP64</dc:creator>
      <dc:date>2006-03-10T22:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: Read and Write Bytes in a Word</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Read-and-Write-Bytes-in-a-Word/m-p/128512#M1714</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi:&lt;BR /&gt;&lt;BR /&gt;If you're using Processor Expert, you can use one of the methods provided by the ATD Bean to read the value as 16 bits.&lt;BR /&gt;&lt;BR /&gt;If you're not using PE, you can use code like:&lt;BR /&gt;(From PE)&lt;BR /&gt;/* 16-bit register (big endian) */&lt;BR /&gt;typedef union {&lt;BR /&gt;word w;&lt;BR /&gt;struct {&lt;BR /&gt;byte high,low;&lt;BR /&gt;} b;&lt;BR /&gt;} TWREG;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;word Read_Sample(void)&lt;BR /&gt;{&lt;BR /&gt;TWREG Sample&lt;BR /&gt;&lt;BR /&gt;Sample.b.high = ATD1RH;&lt;BR /&gt;Sample.b.low = ATD1RL;&lt;BR /&gt;return Sample.w; // Return as word (16 bit)&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Alex&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Mar 2006 01:34:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Read-and-Write-Bytes-in-a-Word/m-p/128512#M1714</guid>
      <dc:creator>alex_spotw</dc:creator>
      <dc:date>2006-03-11T01:34:54Z</dc:date>
    </item>
    <item>
      <title>Re: Read and Write Bytes in a Word</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Read-and-Write-Bytes-in-a-Word/m-p/128513#M1715</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I thought maybe this way.&lt;BR /&gt;&lt;BR /&gt;#define HB(x) x&amp;gt;&amp;gt;8&lt;BR /&gt;#define LB(x) x&amp;amp;0xff&lt;BR /&gt;&lt;BR /&gt;the CodeWarrior' complier can do rest step well.&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Mar 2006 23:45:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Read-and-Write-Bytes-in-a-Word/m-p/128513#M1715</guid>
      <dc:creator>eexpress</dc:creator>
      <dc:date>2006-03-24T23:45:59Z</dc:date>
    </item>
    <item>
      <title>Re: Read and Write Bytes in a Word</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Read-and-Write-Bytes-in-a-Word/m-p/128514#M1716</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;FONT size="2"&gt;Hello,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;The original problem was to combine individual bytes into a word, rather than split a word into individual bytes.&amp;nbsp; However, the macro approach seems a good one.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;#define conv2word(hi,lo) (word)hi*256+(word)lo&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;e.g.&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;word wordval;&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;wordval = conv2word(ATD1RH,ATD1RL);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;The compiler seems to optimise the code&amp;nbsp;better using multiplication rather than a left-shift process.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Regards,&lt;BR /&gt;Mac&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 25 Mar 2006 14:22:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Read-and-Write-Bytes-in-a-Word/m-p/128514#M1716</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2006-03-25T14:22:19Z</dc:date>
    </item>
  </channel>
</rss>

