<?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>S12 / MagniV MicrocontrollersのトピックATD using MC9S12XDT512</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/ATD-using-MC9S12XDT512/m-p/163737#M5247</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone.&amp;nbsp; I'm having problems collecting an analog voltage from an infrared sensor using the MC9S12XDT512.&amp;nbsp; I'm very familiar with the MC9S12C32, so I'm trying to suit my code to this other microcontroller.&amp;nbsp; I'm only using one channel and one infrared sensor.&amp;nbsp; I have a DMM connected to the infrared sensor so I am able to match the voltage variable with the correct output voltage of the infrared sensor.&amp;nbsp; Here's my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;void main(void) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; float voltage;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; ATD0CTL2 = 0b11000000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; ATD0CTL3 = 0b00001000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; ATD0CTL4 = 0b10000001;&amp;nbsp;&amp;nbsp; // 8-bit resolution&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; ATD0CTL5 = 0b00000000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; while(1) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; voltage = (5 * (float)(ATD0DR0H / 256));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ATD0CTL5 = 0b00000000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tested this code using the MC9S12C32 and its functional.&amp;nbsp; When I run this code using the MC9S12XDT512, it throws an error - voltage variable is always 0.&amp;nbsp; Any input and help would be appreciated.&amp;nbsp; Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;d0pplegangah&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 18 Nov 2010 07:28:46 GMT</pubDate>
    <dc:creator>d0pplegangah</dc:creator>
    <dc:date>2010-11-18T07:28:46Z</dc:date>
    <item>
      <title>ATD using MC9S12XDT512</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/ATD-using-MC9S12XDT512/m-p/163737#M5247</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone.&amp;nbsp; I'm having problems collecting an analog voltage from an infrared sensor using the MC9S12XDT512.&amp;nbsp; I'm very familiar with the MC9S12C32, so I'm trying to suit my code to this other microcontroller.&amp;nbsp; I'm only using one channel and one infrared sensor.&amp;nbsp; I have a DMM connected to the infrared sensor so I am able to match the voltage variable with the correct output voltage of the infrared sensor.&amp;nbsp; Here's my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;void main(void) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; float voltage;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; ATD0CTL2 = 0b11000000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; ATD0CTL3 = 0b00001000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; ATD0CTL4 = 0b10000001;&amp;nbsp;&amp;nbsp; // 8-bit resolution&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; ATD0CTL5 = 0b00000000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; while(1) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; voltage = (5 * (float)(ATD0DR0H / 256));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ATD0CTL5 = 0b00000000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tested this code using the MC9S12C32 and its functional.&amp;nbsp; When I run this code using the MC9S12XDT512, it throws an error - voltage variable is always 0.&amp;nbsp; Any input and help would be appreciated.&amp;nbsp; Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;d0pplegangah&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Nov 2010 07:28:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/ATD-using-MC9S12XDT512/m-p/163737#M5247</guid>
      <dc:creator>d0pplegangah</dc:creator>
      <dc:date>2010-11-18T07:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: ATD using MC9S12XDT512</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/ATD-using-MC9S12XDT512/m-p/163738#M5248</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;FONT color="#ff0000"&gt;voltage = (5 * (float)(ATD0DR0H / 256));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here ^^ you first take integer ATD0DR0H and divide it by 256. Result is always 0. Then you convert 0 to float and multiply it by 5. Result is still 0.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Nov 2010 13:12:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/ATD-using-MC9S12XDT512/m-p/163738#M5248</guid>
      <dc:creator>kef</dc:creator>
      <dc:date>2010-11-18T13:12:57Z</dc:date>
    </item>
  </channel>
</rss>

