<?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>8-bit MicrocontrollersのトピックRe: 32 bits Math Operations HCS08</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/32-bits-Math-Operations-HCS08/m-p/392168#M21273</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is how C works. 16 bits operation gives 16 bits result. You need to implicitly cast at least one of multipliers to 32 bits to get 32 bits product. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;temp=(uint32_t)( (uint32_t)adc_result0*Mult);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Edward&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 14 Oct 2015 04:01:16 GMT</pubDate>
    <dc:creator>kef2</dc:creator>
    <dc:date>2015-10-14T04:01:16Z</dc:date>
    <item>
      <title>32 bits Math Operations HCS08</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/32-bits-Math-Operations-HCS08/m-p/392167#M21272</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello All,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new on Codewarrior and in my current project(9S08PA8) I need a 32 bits variable to receive the result of a math operation. &lt;/P&gt;&lt;P&gt;This variable will receive a value from a single&amp;nbsp; multiply operation(eg. ADC_result x 87).&lt;/P&gt;&lt;P&gt;Below a snippet of my code:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;uint8_t Mult=87;&lt;/P&gt;&lt;P&gt;uint32_t temp=0;&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;temp=(uint32_t)(adc_result0*Mult);&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What happens is that if the value of adc_result0 is below or equal to 753 (the result ocupy only 2 bytes) everything is ok, but if the adc_result0 is higher than 753 (the result does not fill in 2 bytes) the compiler casts the result to 2 bytes. My question is can the HCS08 compiler operate in 32 bits variables? If not, what workaround can I use to solve this problem? (I tried to declare the variable as dword, unsigned long, long, without success).&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Oct 2015 19:56:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/32-bits-Math-Operations-HCS08/m-p/392167#M21272</guid>
      <dc:creator>adrianodangelo</dc:creator>
      <dc:date>2015-10-13T19:56:45Z</dc:date>
    </item>
    <item>
      <title>Re: 32 bits Math Operations HCS08</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/32-bits-Math-Operations-HCS08/m-p/392168#M21273</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is how C works. 16 bits operation gives 16 bits result. You need to implicitly cast at least one of multipliers to 32 bits to get 32 bits product. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;temp=(uint32_t)( (uint32_t)adc_result0*Mult);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Edward&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Oct 2015 04:01:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/32-bits-Math-Operations-HCS08/m-p/392168#M21273</guid>
      <dc:creator>kef2</dc:creator>
      <dc:date>2015-10-14T04:01:16Z</dc:date>
    </item>
    <item>
      <title>Re: 32 bits Math Operations HCS08</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/32-bits-Math-Operations-HCS08/m-p/392169#M21274</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Eduards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Perfect! You solved my problem and saved me a lot of time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Oct 2015 10:49:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/32-bits-Math-Operations-HCS08/m-p/392169#M21274</guid>
      <dc:creator>adrianodangelo</dc:creator>
      <dc:date>2015-10-14T10:49:44Z</dc:date>
    </item>
  </channel>
</rss>

