<?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 Reading multiple ADC channels in FIFO mode in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Reading-multiple-ADC-channels-in-FIFO-mode/m-p/1458833#M63109</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to read ADC values from channels 6,7,12, and 13, but somehow ADC_R returns the same values for all depth. Below are my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;SIM_SCGC |= SIM_SCGC_ADC_MASK; /* Enable bus clock in ADC*/
	
ADC_APCTL1 = ADC_APCTL1_ADPC(1&amp;lt;&amp;lt;6) | ADC_APCTL1_ADPC(1&amp;lt;&amp;lt;7) | ADC_APCTL1_ADPC(1&amp;lt;&amp;lt;12)| ADC_APCTL1_ADPC(1&amp;lt;&amp;lt;13); /* Channel selection */	
	
ADC_SC3 = ADC_SC3_ADICLK(0x01) | /* Bus clock divided by 2 */
          ADC_SC3_MODE(0b10) |   /* 12 bit mode operation */ 
          ADC_SC3_ADLPC_MASK |   /* Low power configuration */
	  ADC_SC3_ADIV(0b11);    /* Divide ration = 4, and clock rate = Input clock ÷ 8 */
ADC_SC2 = 0x00;          /* Software trigger selected */	
ADC_SC4 = ADC_SC4_AFDEP(0b011);    /* 4-level FIFO is enabled */

ADC_SC1 = ADC_SC1_ADCH(0x00);  /* dummy the 1st channel */
ADC_SC1 = ADC_SC1_ADCH(0x01);  /* dummy the 2nd channel */
ADC_SC1 = ADC_SC1_ADCH(0x02);  /* dummy the 3rd channel */
ADC_SC1 = ADC_SC1_AIEN_MASK | ADC_SC1_ADCH(0x03); /* dummy the 4th channel and start conversion */&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following code outputs buffer = {4095, 4095, 4095, 4095} when channel 13 is connected to 5V&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ADC_SC1 = ADC_SC1_ADCH(0x06);				
ADC_SC1 = ADC_SC1_ADCH(0x07);									
ADC_SC1 = ADC_SC1_ADCH(0x0C);				
ADC_SC1 = ADC_SC1_ADCH(0x0D); 
while(!(ADC_SC1 &amp;amp; ADC_SC1_COCO_MASK));
buffer[0]=ADC_R;
buffer[1]=ADC_R;
buffer[2]=ADC_R;	
buffer[3]=ADC_R;	&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following code outputs ADC values in the correct sequence&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;ADC_SC1 = ADC_SC1_ADCH(0x06);	
while(!(ADC_SC1 &amp;amp; ADC_SC1_COCO_MASK));
buffer[0]=ADC_R;					
ADC_SC1 = ADC_SC1_ADCH(0x07);			
while(!(ADC_SC1 &amp;amp; ADC_SC1_COCO_MASK));
buffer[1]=ADC_R;									
ADC_SC1 = ADC_SC1_ADCH(0x0C);	
while(!(ADC_SC1 &amp;amp; ADC_SC1_COCO_MASK));
buffer[2]=ADC_R;						
ADC_SC1 = ADC_SC1_ADCH(0x0D); 
while(!(ADC_SC1 &amp;amp; ADC_SC1_COCO_MASK));
buffer[3]=ADC_R;	&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I though FIFO is supposed to read channels in sequence, but since the four sequential ADC_R all read the same values, I'm guessing my code are reading the same channels four times. I would like to have the ADC configured so that FIFO reads four separate channels when triggered. Is there any configuration or clocking problem with my setup?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Mon, 16 May 2022 21:01:03 GMT</pubDate>
    <dc:creator>laonia</dc:creator>
    <dc:date>2022-05-16T21:01:03Z</dc:date>
    <item>
      <title>Reading multiple ADC channels in FIFO mode</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Reading-multiple-ADC-channels-in-FIFO-mode/m-p/1458833#M63109</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to read ADC values from channels 6,7,12, and 13, but somehow ADC_R returns the same values for all depth. Below are my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;SIM_SCGC |= SIM_SCGC_ADC_MASK; /* Enable bus clock in ADC*/
	
ADC_APCTL1 = ADC_APCTL1_ADPC(1&amp;lt;&amp;lt;6) | ADC_APCTL1_ADPC(1&amp;lt;&amp;lt;7) | ADC_APCTL1_ADPC(1&amp;lt;&amp;lt;12)| ADC_APCTL1_ADPC(1&amp;lt;&amp;lt;13); /* Channel selection */	
	
ADC_SC3 = ADC_SC3_ADICLK(0x01) | /* Bus clock divided by 2 */
          ADC_SC3_MODE(0b10) |   /* 12 bit mode operation */ 
          ADC_SC3_ADLPC_MASK |   /* Low power configuration */
	  ADC_SC3_ADIV(0b11);    /* Divide ration = 4, and clock rate = Input clock ÷ 8 */
ADC_SC2 = 0x00;          /* Software trigger selected */	
ADC_SC4 = ADC_SC4_AFDEP(0b011);    /* 4-level FIFO is enabled */

ADC_SC1 = ADC_SC1_ADCH(0x00);  /* dummy the 1st channel */
ADC_SC1 = ADC_SC1_ADCH(0x01);  /* dummy the 2nd channel */
ADC_SC1 = ADC_SC1_ADCH(0x02);  /* dummy the 3rd channel */
ADC_SC1 = ADC_SC1_AIEN_MASK | ADC_SC1_ADCH(0x03); /* dummy the 4th channel and start conversion */&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following code outputs buffer = {4095, 4095, 4095, 4095} when channel 13 is connected to 5V&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ADC_SC1 = ADC_SC1_ADCH(0x06);				
ADC_SC1 = ADC_SC1_ADCH(0x07);									
ADC_SC1 = ADC_SC1_ADCH(0x0C);				
ADC_SC1 = ADC_SC1_ADCH(0x0D); 
while(!(ADC_SC1 &amp;amp; ADC_SC1_COCO_MASK));
buffer[0]=ADC_R;
buffer[1]=ADC_R;
buffer[2]=ADC_R;	
buffer[3]=ADC_R;	&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following code outputs ADC values in the correct sequence&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;ADC_SC1 = ADC_SC1_ADCH(0x06);	
while(!(ADC_SC1 &amp;amp; ADC_SC1_COCO_MASK));
buffer[0]=ADC_R;					
ADC_SC1 = ADC_SC1_ADCH(0x07);			
while(!(ADC_SC1 &amp;amp; ADC_SC1_COCO_MASK));
buffer[1]=ADC_R;									
ADC_SC1 = ADC_SC1_ADCH(0x0C);	
while(!(ADC_SC1 &amp;amp; ADC_SC1_COCO_MASK));
buffer[2]=ADC_R;						
ADC_SC1 = ADC_SC1_ADCH(0x0D); 
while(!(ADC_SC1 &amp;amp; ADC_SC1_COCO_MASK));
buffer[3]=ADC_R;	&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I though FIFO is supposed to read channels in sequence, but since the four sequential ADC_R all read the same values, I'm guessing my code are reading the same channels four times. I would like to have the ADC configured so that FIFO reads four separate channels when triggered. Is there any configuration or clocking problem with my setup?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2022 21:01:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Reading-multiple-ADC-channels-in-FIFO-mode/m-p/1458833#M63109</guid>
      <dc:creator>laonia</dc:creator>
      <dc:date>2022-05-16T21:01:03Z</dc:date>
    </item>
    <item>
      <title>Re: Reading multiple ADC channels in FIFO mode</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Reading-multiple-ADC-channels-in-FIFO-mode/m-p/1459618#M63120</link>
      <description>&lt;P&gt;Hi laonia,&lt;/P&gt;
&lt;P&gt;Seems that you are using KEA MCU. Please refer the example &lt;STRONG&gt;FRDM_KEA128_ADC_FIFO&lt;/STRONG&gt; of&amp;nbsp;&lt;A href="https://www.nxp.com/webapp/Download?colCode=FRDM-KEA-QSP" target="_self"&gt;FRDM-KEAZ Freedom Evaluation Board – QSP&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="FRDM_KEA128_ADC_FIFO.png" style="width: 999px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/180063i824A2F6417E198FF/image-size/large?v=v2&amp;amp;px=999" role="button" title="FRDM_KEA128_ADC_FIFO.png" alt="FRDM_KEA128_ADC_FIFO.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Robin&lt;BR /&gt;-------------------------------------------------------------------------------&lt;BR /&gt;Note:&lt;BR /&gt;- If this post answers your question, please click the "Mark Correct" button. Thank you!&lt;/P&gt;
&lt;P&gt;- We are following threads for 7 weeks after the last post, later replies are ignored&lt;BR /&gt;Please open a new thread and refer to the closed one, if you have a related question at a later point in time.&lt;BR /&gt;-------------------------------------------------------------------------------&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2022 02:33:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Reading-multiple-ADC-channels-in-FIFO-mode/m-p/1459618#M63120</guid>
      <dc:creator>Robin_Shen</dc:creator>
      <dc:date>2022-05-18T02:33:39Z</dc:date>
    </item>
  </channel>
</rss>

