<?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 Help with adc QY4 in 8-bit Microcontrollers</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Help-with-adc-QY4/m-p/174543#M12055</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;hi, I 'm sorry to trouble you, but I can't make that work the adc of QY4, I'm new in the microcontroller freescale, but I start and I need some help., my program is this&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;#include &amp;lt;hidef.h&amp;gt; /* for EnableInterrupts macro */#include &amp;lt;MC68HC908QY4.h&amp;gt; /* include peripheral declarations */#include &amp;lt;startup.h&amp;gt;unsigned char result;void interrupt 16 ADC_ISR(void){&amp;nbsp; result=ADR;&amp;nbsp; }void inicializacion(void);void main(void) {&amp;nbsp; inicializacion();&amp;nbsp;&amp;nbsp;&amp;nbsp; ADICLK=0x80;&amp;nbsp; ADSCR = 0x43;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(;;){&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (!ADSCR_COCO);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result=ADR;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTB= result;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* loop forever */&amp;nbsp; /* please make sure that you never leave this function */}void inicializacion(){&amp;nbsp;&amp;nbsp; CONFIG1=0x09; CONFIG2=0x80; OSCTRIM=0x80;&amp;nbsp; DDRB=0xFF;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;&amp;nbsp;please, could you put an easy example of adc in c&lt;BR /&gt;&lt;BR /&gt;thanks, and I'm sorry for my english, I promise to learn speak english&lt;BR /&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 29 Oct 2020 09:23:19 GMT</pubDate>
    <dc:creator>scientist</dc:creator>
    <dc:date>2020-10-29T09:23:19Z</dc:date>
    <item>
      <title>Help with adc QY4</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Help-with-adc-QY4/m-p/174543#M12055</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;hi, I 'm sorry to trouble you, but I can't make that work the adc of QY4, I'm new in the microcontroller freescale, but I start and I need some help., my program is this&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;#include &amp;lt;hidef.h&amp;gt; /* for EnableInterrupts macro */#include &amp;lt;MC68HC908QY4.h&amp;gt; /* include peripheral declarations */#include &amp;lt;startup.h&amp;gt;unsigned char result;void interrupt 16 ADC_ISR(void){&amp;nbsp; result=ADR;&amp;nbsp; }void inicializacion(void);void main(void) {&amp;nbsp; inicializacion();&amp;nbsp;&amp;nbsp;&amp;nbsp; ADICLK=0x80;&amp;nbsp; ADSCR = 0x43;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(;;){&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (!ADSCR_COCO);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result=ADR;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTB= result;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* loop forever */&amp;nbsp; /* please make sure that you never leave this function */}void inicializacion(){&amp;nbsp;&amp;nbsp; CONFIG1=0x09; CONFIG2=0x80; OSCTRIM=0x80;&amp;nbsp; DDRB=0xFF;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;&amp;nbsp;please, could you put an easy example of adc in c&lt;BR /&gt;&lt;BR /&gt;thanks, and I'm sorry for my english, I promise to learn speak english&lt;BR /&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:23:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Help-with-adc-QY4/m-p/174543#M12055</guid>
      <dc:creator>scientist</dc:creator>
      <dc:date>2020-10-29T09:23:19Z</dc:date>
    </item>
    <item>
      <title>Re: Help with adc QY4</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Help-with-adc-QY4/m-p/174544#M12056</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Hello,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;There&amp;nbsp;seem to be&amp;nbsp;a number of problems with your code -&lt;/DIV&gt;&lt;OL&gt;&lt;LI&gt;You have enabled the ADC interrupt, but then proceed to poll the COCO flag within the main loop.&amp;nbsp; However, the COCO bit will always read as&amp;nbsp;zero when the&amp;nbsp;interrupt&amp;nbsp;is enabled.&amp;nbsp; Initially, I would suggest that you disable the ADC interrupt, and poll&amp;nbsp;conversion complete flag.&lt;/LI&gt;&lt;LI&gt;You have selected the ADC clock to be Bus_clk/16.&amp;nbsp; Assuming you are using the internal oscillator (Bus_clk = 3.2MHz), the divider value will need to be Bus_clk/4, for the ADC to operate correctly.&lt;/LI&gt;&lt;LI&gt;Since you have selected single conversion mode, the ADSCR register will need to be written to start each conversion - your code only writes the register once.&lt;/LI&gt;&lt;/OL&gt;&lt;DIV&gt;I assume that the analog signal is present at the PTA5 (AN3) pin, and that you are actually using a 'QY4 device.&amp;nbsp; This device is practically obsolete, and has been replaced by the 'QY4A device.&amp;nbsp; The later device has a different ADC module, and its setup may differ from the earlier one.&amp;nbsp; The following code assumes the 'QY4.&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;void main(void) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;byte result;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="Courier New"&gt;&amp;nbsp; inicializacion();&lt;BR /&gt;&amp;nbsp; ADICLK = 0x40;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// Assumes internal&amp;nbsp;oscillator&lt;BR /&gt;&amp;nbsp; for( ; ; ) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ADSCR = 0x03;&amp;nbsp; // Start conversion - AN3 channel&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; while (!ADSCR_COCO);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result = ADR;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; PTB = result;&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;}&lt;BR /&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;Mac&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jul 2008 14:16:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Help-with-adc-QY4/m-p/174544#M12056</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2008-07-21T14:16:13Z</dc:date>
    </item>
    <item>
      <title>Re: Help with adc QY4</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Help-with-adc-QY4/m-p/174545#M12057</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;thanks bigmac, its just what I needed, thank you very much, I goind to see it's works &lt;SPAN&gt;&lt;IMG alt=":smileyvery-happy:" class="emoticon emoticon-smileyvery-happy" id="smileyvery-happy" src="http://freescale.i.lithium.com/i/smilies/16x16_smiley-very-happy.gif" title="Smiley Very Happy" /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jul 2008 23:25:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Help-with-adc-QY4/m-p/174545#M12057</guid>
      <dc:creator>scientist</dc:creator>
      <dc:date>2008-07-21T23:25:12Z</dc:date>
    </item>
    <item>
      <title>Re: Help with adc QY4</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Help-with-adc-QY4/m-p/174546#M12058</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;doesn't work, I don't know why, I put this program&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;DIV class="msg_source_code"&gt;&lt;DIV class="text_smallest"&gt;Code:&lt;/DIV&gt;&lt;PRE&gt;#include &amp;lt;hidef.h&amp;gt; /* for EnableInterrupts macro */#include "derivative.h" /* include peripheral declarations */#include &amp;lt;startup.h&amp;gt;  void inicializacion(void);void main(void) {       byte result;   inicializacion();  ADICLK = 0x40;     // Assumes internal oscillator  for( ; ; ) {      ADSCR = 0x03;  // Start conversion - AN3 channel      while (!ADSCR_COCO);      result = ADR;      PTB = result;  }}   /* loop forever */  /* please make sure that you never leave main */void inicializacion(){   CONFIG1=0x09; CONFIG2=0x00; OSCTRIM=0x80;  DDRB=0xFF;   }&lt;/PRE&gt;&lt;/DIV&gt;&lt;BR /&gt;&amp;nbsp;and I can't see nothing in the port B, what's wrong whit my code?&lt;BR /&gt;&lt;BR /&gt;thanks again&lt;BR /&gt;&lt;BR /&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:23:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Help-with-adc-QY4/m-p/174546#M12058</guid>
      <dc:creator>scientist</dc:creator>
      <dc:date>2020-10-29T09:23:21Z</dc:date>
    </item>
    <item>
      <title>Re: Help with adc QY4</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Help-with-adc-QY4/m-p/174547#M12059</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;Hello,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;A few questions -&lt;/DIV&gt;&lt;OL&gt;&lt;LI&gt;Have you checked that the device you are using is actually a 'QY4, and not a 'QY4A type?&lt;/LI&gt;&lt;LI&gt;Have you programmed the device with the code, and are running in stand-alone manner, (i.e. you are &lt;U&gt;not&lt;/U&gt; attempting to use full chip simulation within the debugger)?&lt;/LI&gt;&lt;LI&gt;What analog voltage level is being applied to the PTA5 (AN3) pin?&lt;/LI&gt;&lt;LI&gt;How are you monitoring the state of port B, perhaps using LEDs.&amp;nbsp; If so, a substantial delay between each reading may help.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jul 2008 18:27:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Help-with-adc-QY4/m-p/174547#M12059</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2008-07-22T18:27:27Z</dc:date>
    </item>
    <item>
      <title>Re: Help with adc QY4</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Help-with-adc-QY4/m-p/174548#M12060</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hi, i´m sorry, I check my circuit in protoboard, and the potenciometro (I don´t know how I say to english) doesn't work right, so I change the potenciometro and work good the micro, thanks, and como decimos en mi tierra muchas gracias, saludos&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jul 2008 22:57:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Help-with-adc-QY4/m-p/174548#M12060</guid>
      <dc:creator>scientist</dc:creator>
      <dc:date>2008-07-22T22:57:10Z</dc:date>
    </item>
  </channel>
</rss>

