<?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のトピックS08 ADC</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-ADC/m-p/168416#M11026</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;Greetings all,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;I am implementing a single channel Analog-to-Digital read, using MC9S08LC60, but I am having inconsistent results.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;Here is my setup:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;* In most use the module is connected to a 12V battery, and it also uses 3V backup batteries&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;* A regulator drops the 12V to 3.3V&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;* A diode is between the 3.3V and the backup batteries, with the feed going to the MCU's Vdd&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;* The Vdd while on the backups is 2.8-2.9V&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;* PTA0 has a line going to a point between the regulator and the diode, hence the read will be approx. 3.3V when the 12V is connected&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;* The current draw is 3.7mA in run&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;* PTA0 is initialized before the main loop:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;MOV&lt;/SPAN&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;#%00010000,ADCCFG &lt;/SPAN&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;; ADC&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;MOV&lt;/SPAN&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;#%00000001,APCTL1 &lt;/SPAN&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;; Enable PTA0 as a ADC pin&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;* Then in a quarter second loop:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;CLR&lt;/SPAN&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;ADCSC1&lt;/SPAN&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;; COCO, AIEN, ADCO, ADCH (4:0)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;NOP&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;NOP&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;LDA&lt;/SPAN&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;ADCRL&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;CMP&lt;/SPAN&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;#250&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;BHI&lt;/SPAN&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;xxxx &lt;/SPAN&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;; &amp;gt;250 = voltage from VR, 3.2V, lower V if only from internal batts&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;Sometimes it does not load ADCRL into A, hence a false branch occurs. Moreover, I could use this read very early in Vreset but it is even more inconsistent there.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;Note that every ADC read follows a port initialization and that with a PE BDM the correct values are shown in ADCRL, $FF when the 12V source is connected and approx. one half that value when on backup batteries (2.8-2.9VDC). But it doesn't consistently load ADCRL and the failure results in $00 in A with the debugger showing $FF in ADCRL, if on 12V.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;What can be done to make each read reliable?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;KM&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 09 Dec 2010 05:43:47 GMT</pubDate>
    <dc:creator>KerryMac</dc:creator>
    <dc:date>2010-12-09T05:43:47Z</dc:date>
    <item>
      <title>S08 ADC</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-ADC/m-p/168416#M11026</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;Greetings all,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;I am implementing a single channel Analog-to-Digital read, using MC9S08LC60, but I am having inconsistent results.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;Here is my setup:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;* In most use the module is connected to a 12V battery, and it also uses 3V backup batteries&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;* A regulator drops the 12V to 3.3V&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;* A diode is between the 3.3V and the backup batteries, with the feed going to the MCU's Vdd&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;* The Vdd while on the backups is 2.8-2.9V&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;* PTA0 has a line going to a point between the regulator and the diode, hence the read will be approx. 3.3V when the 12V is connected&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;* The current draw is 3.7mA in run&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;* PTA0 is initialized before the main loop:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;MOV&lt;/SPAN&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;#%00010000,ADCCFG &lt;/SPAN&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;; ADC&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;MOV&lt;/SPAN&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;#%00000001,APCTL1 &lt;/SPAN&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;; Enable PTA0 as a ADC pin&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;* Then in a quarter second loop:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;CLR&lt;/SPAN&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;ADCSC1&lt;/SPAN&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;; COCO, AIEN, ADCO, ADCH (4:0)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;NOP&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;NOP&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;LDA&lt;/SPAN&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;ADCRL&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;CMP&lt;/SPAN&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;#250&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;BHI&lt;/SPAN&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;xxxx &lt;/SPAN&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;; &amp;gt;250 = voltage from VR, 3.2V, lower V if only from internal batts&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;Sometimes it does not load ADCRL into A, hence a false branch occurs. Moreover, I could use this read very early in Vreset but it is even more inconsistent there.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;Note that every ADC read follows a port initialization and that with a PE BDM the correct values are shown in ADCRL, $FF when the 12V source is connected and approx. one half that value when on backup batteries (2.8-2.9VDC). But it doesn't consistently load ADCRL and the failure results in $00 in A with the debugger showing $FF in ADCRL, if on 12V.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;What can be done to make each read reliable?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: small; font-family: ''courier new', courier';"&gt;KM&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Dec 2010 05:43:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-ADC/m-p/168416#M11026</guid>
      <dc:creator>KerryMac</dc:creator>
      <dc:date>2010-12-09T05:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: S08 ADC</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-ADC/m-p/168417#M11027</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello KM,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From your description PTA0 would seem to be effectively connected to Vdd - is this&amp;nbsp;the case?&amp;nbsp; You do not mention&amp;nbsp;your connection for VrefH. &amp;nbsp;If connected to VddAD, you should get&amp;nbsp;readings very close to maximum reading every time, independent of Vdd.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A better approach might be to measure the internal bandgap reference.&amp;nbsp; For a Vdd of 3.3 volt, the 8-bit reading should be in the vicinity of 93.&amp;nbsp; When Vdd drops to 2.9 volt, the reading should &lt;U&gt;increase&lt;/U&gt; to about 106.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the 12 volt supply is never present when running from batteries, another approach is to feed this point to PTA0, via a suitable voltage divider.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After a POR, you should wait a sufficient time for Vdd to stabilize.&amp;nbsp; This may take&amp;nbsp;tens of&amp;nbsp;milliseconds after POR, depending on bulk capacitors present, and other factors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I notice that your code does not wait until COCO flag becomes set before attempting to read ADCRL.&amp;nbsp; Two NOP instructions would be insufficient to complete the conversion.&amp;nbsp; Since this part of the code executes every 250 ms, a variation would be to read the previous result, and then commence the next conversion.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;LDA  ADCRL       ; Read previous resultMOV  #0,ADCSC1   ; Commence next readingCMP #xxxBHI xxxx&lt;/PRE&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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:16:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-ADC/m-p/168417#M11027</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2020-10-29T09:16:02Z</dc:date>
    </item>
    <item>
      <title>Re: S08 ADC</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-ADC/m-p/168418#M11028</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks bigmac,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your suggestion of imbedding a ADC read in the 250 ms routine, along with reading the ADCRL value from the previous 250 ms loop, worked well. Allowing a sufficient period for consistent reads allowed me to complete this project.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ADC is new to me and I will put aside some time in the future to develop a full understanding of all of it's nuances.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;&lt;P&gt;KM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Dec 2010 22:44:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/S08-ADC/m-p/168418#M11028</guid>
      <dc:creator>KerryMac</dc:creator>
      <dc:date>2010-12-13T22:44:31Z</dc:date>
    </item>
  </channel>
</rss>

