<?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 Multichannel ADC S12 in S12 / MagniV Microcontrollers</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Multichannel-ADC-S12/m-p/815535#M15830</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, everyone.&lt;/P&gt;&lt;P&gt;I have a problem, when I use multi-channel ADC, only AN0 and AN1 are enabled, but their readings are the same. I can read different data when my ATDCTL0 exceeds the sequence, but I think the data in one of the channels is read at different times.&lt;/P&gt;&lt;P&gt;My main chip is S12VR48.&lt;/P&gt;&lt;P&gt;/************************************************************************************/&lt;/P&gt;&lt;P&gt;void ADC_Double_init(void) //非中断&lt;BR /&gt;{&lt;BR /&gt; ATDCTL0 = 0x01; //多通道转化的序列环绕到AN1&lt;BR /&gt; ATDCTL1 = 0X00; // 0000 0000 8位采样精度 采样前不放电（放电可能导致问题）&lt;BR /&gt; ATDCTL2 = 0x00; // 0000 0000 外部触发禁止 中断禁止 禁止快清&lt;BR /&gt; ATDCTL3 = 0x90; &lt;BR /&gt; //右对齐、数据长度2 冻结模式下继续转换 FIFO不启动&lt;BR /&gt; ATDCTL4 = 0xab; // 1010 1011 16AD采样时间 Fad = 1MHZ &lt;BR /&gt; /* fATDCLK = fBUS / (2*(PRS + 1)) Fadcclk=1MHz=24MHz/24*/ &lt;BR /&gt; ATDCTL5 = 0x31; //0011 0001 连续转换 多通道 AN1选择&lt;BR /&gt; ATDDIEN = 0X00; //禁用数字输入缓冲器到ANx pin&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;This is the initialization setting of ADC.&lt;/P&gt;&lt;P&gt;/**********************************************************************************/&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/76046i49C4860949E6E824/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;When my ATDCTL0 exceeds AN1, the reading becomes different, but if one channel is grounded the other becomes zero.&lt;/P&gt;&lt;P&gt;/*********************************************************************************/&lt;/P&gt;&lt;P&gt;void main(void) {&lt;BR /&gt; /* put your own code here */&lt;BR /&gt; MCUinit();&lt;BR /&gt; SwitchPowerModuleInit();&lt;BR /&gt; HS0On();&lt;BR /&gt; ADC_Double_init();&lt;BR /&gt; // PWMinit_PWM45(); &lt;BR /&gt; MotorControlInit();&lt;BR /&gt; EnableInterrupts; //开放总中断&lt;BR /&gt; for(;;) //TEMP&lt;BR /&gt; {&lt;BR /&gt; while(!ATDSTAT0_SCF); // 等待转换结束，退出循环&lt;BR /&gt; ad_value_0=ATDDR0;&lt;BR /&gt; Delay(800); // 延时&lt;BR /&gt; ATDSTAT2L= ATDSTAT2L_CCF0_MASK; /*清标志位*/&lt;BR /&gt; ATDSTAT2L= ATDSTAT2L_CCF1_MASK; /*清标志位*/&lt;BR /&gt; ATDSTAT0 = ATDSTAT0_SCF_MASK; /*序列转换标志位*/&lt;BR /&gt; Sequence_Data = ATDSTAT0_CC; /*取出序列的数据序列*/&lt;BR /&gt; if (Sequence_Data==1)&lt;BR /&gt; {&lt;BR /&gt; ad_value_1=ATDDR1;&lt;BR /&gt; }&lt;BR /&gt; //ad_value_1=ATDDR0;&lt;BR /&gt; &lt;BR /&gt; Delay(800); // 延时&lt;BR /&gt; if (ad_value_0 &amp;gt; ad_value_1)&lt;BR /&gt; {&lt;BR /&gt; MotorControlForwardOn();&lt;BR /&gt; }&lt;BR /&gt; else&lt;BR /&gt; MotorControlForwardOff();&lt;BR /&gt; //_FEED_COP(); /* feeds the dog */ &lt;BR /&gt; } &lt;BR /&gt; /* loop forever */ &lt;BR /&gt; /* please make sure that you never leave main */ &lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;here is my main code&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 22 Oct 2018 03:53:59 GMT</pubDate>
    <dc:creator>563451665</dc:creator>
    <dc:date>2018-10-22T03:53:59Z</dc:date>
    <item>
      <title>Multichannel ADC S12</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Multichannel-ADC-S12/m-p/815535#M15830</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, everyone.&lt;/P&gt;&lt;P&gt;I have a problem, when I use multi-channel ADC, only AN0 and AN1 are enabled, but their readings are the same. I can read different data when my ATDCTL0 exceeds the sequence, but I think the data in one of the channels is read at different times.&lt;/P&gt;&lt;P&gt;My main chip is S12VR48.&lt;/P&gt;&lt;P&gt;/************************************************************************************/&lt;/P&gt;&lt;P&gt;void ADC_Double_init(void) //非中断&lt;BR /&gt;{&lt;BR /&gt; ATDCTL0 = 0x01; //多通道转化的序列环绕到AN1&lt;BR /&gt; ATDCTL1 = 0X00; // 0000 0000 8位采样精度 采样前不放电（放电可能导致问题）&lt;BR /&gt; ATDCTL2 = 0x00; // 0000 0000 外部触发禁止 中断禁止 禁止快清&lt;BR /&gt; ATDCTL3 = 0x90; &lt;BR /&gt; //右对齐、数据长度2 冻结模式下继续转换 FIFO不启动&lt;BR /&gt; ATDCTL4 = 0xab; // 1010 1011 16AD采样时间 Fad = 1MHZ &lt;BR /&gt; /* fATDCLK = fBUS / (2*(PRS + 1)) Fadcclk=1MHz=24MHz/24*/ &lt;BR /&gt; ATDCTL5 = 0x31; //0011 0001 连续转换 多通道 AN1选择&lt;BR /&gt; ATDDIEN = 0X00; //禁用数字输入缓冲器到ANx pin&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;This is the initialization setting of ADC.&lt;/P&gt;&lt;P&gt;/**********************************************************************************/&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/76046i49C4860949E6E824/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;When my ATDCTL0 exceeds AN1, the reading becomes different, but if one channel is grounded the other becomes zero.&lt;/P&gt;&lt;P&gt;/*********************************************************************************/&lt;/P&gt;&lt;P&gt;void main(void) {&lt;BR /&gt; /* put your own code here */&lt;BR /&gt; MCUinit();&lt;BR /&gt; SwitchPowerModuleInit();&lt;BR /&gt; HS0On();&lt;BR /&gt; ADC_Double_init();&lt;BR /&gt; // PWMinit_PWM45(); &lt;BR /&gt; MotorControlInit();&lt;BR /&gt; EnableInterrupts; //开放总中断&lt;BR /&gt; for(;;) //TEMP&lt;BR /&gt; {&lt;BR /&gt; while(!ATDSTAT0_SCF); // 等待转换结束，退出循环&lt;BR /&gt; ad_value_0=ATDDR0;&lt;BR /&gt; Delay(800); // 延时&lt;BR /&gt; ATDSTAT2L= ATDSTAT2L_CCF0_MASK; /*清标志位*/&lt;BR /&gt; ATDSTAT2L= ATDSTAT2L_CCF1_MASK; /*清标志位*/&lt;BR /&gt; ATDSTAT0 = ATDSTAT0_SCF_MASK; /*序列转换标志位*/&lt;BR /&gt; Sequence_Data = ATDSTAT0_CC; /*取出序列的数据序列*/&lt;BR /&gt; if (Sequence_Data==1)&lt;BR /&gt; {&lt;BR /&gt; ad_value_1=ATDDR1;&lt;BR /&gt; }&lt;BR /&gt; //ad_value_1=ATDDR0;&lt;BR /&gt; &lt;BR /&gt; Delay(800); // 延时&lt;BR /&gt; if (ad_value_0 &amp;gt; ad_value_1)&lt;BR /&gt; {&lt;BR /&gt; MotorControlForwardOn();&lt;BR /&gt; }&lt;BR /&gt; else&lt;BR /&gt; MotorControlForwardOff();&lt;BR /&gt; //_FEED_COP(); /* feeds the dog */ &lt;BR /&gt; } &lt;BR /&gt; /* loop forever */ &lt;BR /&gt; /* please make sure that you never leave main */ &lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;here is my main code&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Oct 2018 03:53:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Multichannel-ADC-S12/m-p/815535#M15830</guid>
      <dc:creator>563451665</dc:creator>
      <dc:date>2018-10-22T03:53:59Z</dc:date>
    </item>
    <item>
      <title>Re: Multichannel ADC S12</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Multichannel-ADC-S12/m-p/815536#M15831</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;to say truth I am "a little bit" confused of your description of the issue and using the ADC module.&lt;/P&gt;&lt;P&gt;Why to use continuous conversion and then insert delay in the code. Next conversions are performed and I have info about completion of the first one (SCF).&lt;/P&gt;&lt;P&gt;Why you convert to channels if it is enough to convert one channel either in continuous mode or as a simple sequence at the right moment?&lt;/P&gt;&lt;P&gt;Channel AN0 is reserved so its value does not have any sense.&lt;/P&gt;&lt;P&gt;If you want to be absolute sure of conversion then use discharge Sample capacitor feature (ATDCTL1).&lt;/P&gt;&lt;P&gt;During debugging I suggest to use to also enable feature Finish conversion then freeze (ATDCTL3).&lt;BR /&gt;the easiest would be to know what do you exactly want to do (flow chart) and on the basis of expectations to select proper mode of converter.&lt;/P&gt;&lt;P&gt;Moreover, I hope you know the results are always stored in ATDDR registers from ATDDR0. For exampel, if I convert channels 4,5,6 the results will be in ATDDR 0,1,2.&lt;/P&gt;&lt;P&gt;best regards,&lt;/P&gt;&lt;P&gt;Ladislav&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Oct 2018 13:55:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/Multichannel-ADC-S12/m-p/815536#M15831</guid>
      <dc:creator>lama</dc:creator>
      <dc:date>2018-10-30T13:55:18Z</dc:date>
    </item>
  </channel>
</rss>

