<?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>Kinetis MicrocontrollersのトピックInconsistency of ADC Conversion value</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Inconsistency-of-ADC-Conversion-value/m-p/708985#M43502</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am using&amp;nbsp;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;MKL03Z32VFG4 and using the ADC0 peripheral for measuring voltage.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;I am using the internal voltage reference. I have seen that when I have under 1.0 volts on the analog pin, I have a certain value the ADC returns. Then if I increase to 1.1volts, the value is smaller than at 1.0 volts. And subsequently, as I go on increasing voltage on the analog pin, the values that the ADC returns are incrementing / decrementing together with the increment/decrement of the voltage.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;Please let me know how can I get rid of that value going low even though the voltage level on the pin is higher.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;My code is as follows:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;================================&lt;/P&gt;&lt;P&gt;#define BATT_ADC16_BASE ADC0&lt;BR /&gt;#define BATT_ADC16_CHANNEL_GROUP 0U &lt;BR /&gt;#define BATT_ADC16_USER_CHANNEL 15U /* PTA0, ADC0_SE15 */&lt;/P&gt;&lt;P&gt;#define BATT_ADC16_IRQn ADC0_IRQn&lt;/P&gt;&lt;P&gt;#define BATT_VOLTAGE_READING_AVAILABLE ADC0_IRQHandler&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void batt_mon_init(){&lt;/P&gt;&lt;P&gt;EnableIRQ(BATT_ADC16_IRQn);&lt;BR /&gt;ADC16_GetDefaultConfig(&amp;amp;adc16ConfigStruct);&lt;BR /&gt; adc16ConfigStruct.clockDivider = kADC16_ClockDivider1;&lt;BR /&gt; adc16ConfigStruct.referenceVoltageSource = kADC16_ReferenceVoltageSourceValt;&lt;BR /&gt; adc16ConfigStruct.enableHighSpeed = true;&lt;BR /&gt; ADC16_Init(BATT_ADC16_BASE, &amp;amp;adc16ConfigStruct);&lt;BR /&gt; ADC16_EnableHardwareTrigger(BATT_ADC16_BASE, false); /* Make sure the software trigger is used. */&lt;BR /&gt;#if defined(FSL_FEATURE_ADC16_HAS_CALIBRATION) &amp;amp;&amp;amp; FSL_FEATURE_ADC16_HAS_CALIBRATION&lt;BR /&gt; if (kStatus_Success != ADC16_DoAutoCalibration(BATT_ADC16_BASE)) &lt;BR /&gt; {&lt;BR /&gt; LOG_E("ADC16_DoAutoCalibration() Failed.\r\n");&lt;BR /&gt; }&lt;BR /&gt;#endif /* FSL_FEATURE_ADC16_HAS_CALIBRATION */&lt;/P&gt;&lt;P&gt;adc16ChannelConfigStruct.channelNumber = BATT_ADC16_USER_CHANNEL;&lt;BR /&gt; adc16ChannelConfigStruct.enableInterruptOnConversionCompleted = true; /* Enable the interrupt. */&lt;BR /&gt;#if defined(FSL_FEATURE_ADC16_HAS_DIFF_MODE) &amp;amp;&amp;amp; FSL_FEATURE_ADC16_HAS_DIFF_MODE&lt;BR /&gt; adc16ChannelConfigStruct.enableDifferentialConversion = false;&lt;BR /&gt;#endif /* FSL_FEATURE_ADC16_HAS_DIFF_MODE */&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void read_battery_level(){&lt;/P&gt;&lt;P&gt;g_Adc16ConversionDoneFlag = false;&lt;BR /&gt; /*&lt;BR /&gt; When in software trigger mode, each conversion would be launched once calling the "ADC16_ChannelConfigure()"&lt;BR /&gt; function, which works like writing a conversion command and executing it. For another channel's conversion,&lt;BR /&gt; just to change the "channelNumber" field in channel configuration structure, and call the function&lt;BR /&gt; "ADC16_ChannelConfigure()"" again.&lt;BR /&gt; Also, the "enableInterruptOnConversionCompleted" inside the channel configuration structure is a parameter for&lt;BR /&gt; the conversion command. It takes affect just for the current conversion. If the interrupt is still required&lt;BR /&gt; for the following conversion, it is necessary to assert the "enableInterruptOnConversionCompleted" every time&lt;BR /&gt; for each command.&lt;BR /&gt; */&lt;BR /&gt; ADC16_SetChannelConfig(BATT_ADC16_BASE, BATT_ADC16_CHANNEL_GROUP, &amp;amp;adc16ChannelConfigStruct);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void BATT_VOLTAGE_READING_AVAILABLE(void)&lt;BR /&gt;{&lt;BR /&gt; g_Adc16ConversionDoneFlag = true;&lt;BR /&gt; static volatile uint32_t avgAdc16ConvValue = 0;&lt;BR /&gt; static volatile int i=0;&lt;BR /&gt; /* Read conversion result to clear the conversion completed flag. */&lt;BR /&gt; volatile uint32_t adc16ConversionValue = ADC16_GetChannelConversionValue(BATT_ADC16_BASE, BATT_ADC16_CHANNEL_GROUP);&lt;BR /&gt; &lt;BR /&gt; if(i&amp;lt;200){&lt;BR /&gt; if (i==0) avgAdc16ConvValue = adc16ConversionValue;&lt;BR /&gt; uint32_t quotient = (avgAdc16ConvValue+adc16ConversionValue)/2;&lt;BR /&gt; uint32_t remainder = (avgAdc16ConvValue+adc16ConversionValue)%2;&lt;BR /&gt; avgAdc16ConvValue = quotient+remainder;&lt;BR /&gt; }&lt;BR /&gt; i++;&lt;/P&gt;&lt;P&gt;if (i == 200){&lt;BR /&gt; i=0;&lt;BR /&gt; (void) enqueueEvent( mainEventQueue, ADC_MEASUREMENT_AVAILABLE, (invisible_event_params_t) { .uIntVal = avgAdc16ConvValue }, event_batt_measurement_available );&lt;BR /&gt; }&lt;BR /&gt; else{&lt;BR /&gt; read_battery_level();&lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;=====================&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Gaurav.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 20 Sep 2017 07:23:42 GMT</pubDate>
    <dc:creator>gauravbanyal</dc:creator>
    <dc:date>2017-09-20T07:23:42Z</dc:date>
    <item>
      <title>Inconsistency of ADC Conversion value</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Inconsistency-of-ADC-Conversion-value/m-p/708985#M43502</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am using&amp;nbsp;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;MKL03Z32VFG4 and using the ADC0 peripheral for measuring voltage.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;I am using the internal voltage reference. I have seen that when I have under 1.0 volts on the analog pin, I have a certain value the ADC returns. Then if I increase to 1.1volts, the value is smaller than at 1.0 volts. And subsequently, as I go on increasing voltage on the analog pin, the values that the ADC returns are incrementing / decrementing together with the increment/decrement of the voltage.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;Please let me know how can I get rid of that value going low even though the voltage level on the pin is higher.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;My code is as follows:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;================================&lt;/P&gt;&lt;P&gt;#define BATT_ADC16_BASE ADC0&lt;BR /&gt;#define BATT_ADC16_CHANNEL_GROUP 0U &lt;BR /&gt;#define BATT_ADC16_USER_CHANNEL 15U /* PTA0, ADC0_SE15 */&lt;/P&gt;&lt;P&gt;#define BATT_ADC16_IRQn ADC0_IRQn&lt;/P&gt;&lt;P&gt;#define BATT_VOLTAGE_READING_AVAILABLE ADC0_IRQHandler&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void batt_mon_init(){&lt;/P&gt;&lt;P&gt;EnableIRQ(BATT_ADC16_IRQn);&lt;BR /&gt;ADC16_GetDefaultConfig(&amp;amp;adc16ConfigStruct);&lt;BR /&gt; adc16ConfigStruct.clockDivider = kADC16_ClockDivider1;&lt;BR /&gt; adc16ConfigStruct.referenceVoltageSource = kADC16_ReferenceVoltageSourceValt;&lt;BR /&gt; adc16ConfigStruct.enableHighSpeed = true;&lt;BR /&gt; ADC16_Init(BATT_ADC16_BASE, &amp;amp;adc16ConfigStruct);&lt;BR /&gt; ADC16_EnableHardwareTrigger(BATT_ADC16_BASE, false); /* Make sure the software trigger is used. */&lt;BR /&gt;#if defined(FSL_FEATURE_ADC16_HAS_CALIBRATION) &amp;amp;&amp;amp; FSL_FEATURE_ADC16_HAS_CALIBRATION&lt;BR /&gt; if (kStatus_Success != ADC16_DoAutoCalibration(BATT_ADC16_BASE)) &lt;BR /&gt; {&lt;BR /&gt; LOG_E("ADC16_DoAutoCalibration() Failed.\r\n");&lt;BR /&gt; }&lt;BR /&gt;#endif /* FSL_FEATURE_ADC16_HAS_CALIBRATION */&lt;/P&gt;&lt;P&gt;adc16ChannelConfigStruct.channelNumber = BATT_ADC16_USER_CHANNEL;&lt;BR /&gt; adc16ChannelConfigStruct.enableInterruptOnConversionCompleted = true; /* Enable the interrupt. */&lt;BR /&gt;#if defined(FSL_FEATURE_ADC16_HAS_DIFF_MODE) &amp;amp;&amp;amp; FSL_FEATURE_ADC16_HAS_DIFF_MODE&lt;BR /&gt; adc16ChannelConfigStruct.enableDifferentialConversion = false;&lt;BR /&gt;#endif /* FSL_FEATURE_ADC16_HAS_DIFF_MODE */&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void read_battery_level(){&lt;/P&gt;&lt;P&gt;g_Adc16ConversionDoneFlag = false;&lt;BR /&gt; /*&lt;BR /&gt; When in software trigger mode, each conversion would be launched once calling the "ADC16_ChannelConfigure()"&lt;BR /&gt; function, which works like writing a conversion command and executing it. For another channel's conversion,&lt;BR /&gt; just to change the "channelNumber" field in channel configuration structure, and call the function&lt;BR /&gt; "ADC16_ChannelConfigure()"" again.&lt;BR /&gt; Also, the "enableInterruptOnConversionCompleted" inside the channel configuration structure is a parameter for&lt;BR /&gt; the conversion command. It takes affect just for the current conversion. If the interrupt is still required&lt;BR /&gt; for the following conversion, it is necessary to assert the "enableInterruptOnConversionCompleted" every time&lt;BR /&gt; for each command.&lt;BR /&gt; */&lt;BR /&gt; ADC16_SetChannelConfig(BATT_ADC16_BASE, BATT_ADC16_CHANNEL_GROUP, &amp;amp;adc16ChannelConfigStruct);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void BATT_VOLTAGE_READING_AVAILABLE(void)&lt;BR /&gt;{&lt;BR /&gt; g_Adc16ConversionDoneFlag = true;&lt;BR /&gt; static volatile uint32_t avgAdc16ConvValue = 0;&lt;BR /&gt; static volatile int i=0;&lt;BR /&gt; /* Read conversion result to clear the conversion completed flag. */&lt;BR /&gt; volatile uint32_t adc16ConversionValue = ADC16_GetChannelConversionValue(BATT_ADC16_BASE, BATT_ADC16_CHANNEL_GROUP);&lt;BR /&gt; &lt;BR /&gt; if(i&amp;lt;200){&lt;BR /&gt; if (i==0) avgAdc16ConvValue = adc16ConversionValue;&lt;BR /&gt; uint32_t quotient = (avgAdc16ConvValue+adc16ConversionValue)/2;&lt;BR /&gt; uint32_t remainder = (avgAdc16ConvValue+adc16ConversionValue)%2;&lt;BR /&gt; avgAdc16ConvValue = quotient+remainder;&lt;BR /&gt; }&lt;BR /&gt; i++;&lt;/P&gt;&lt;P&gt;if (i == 200){&lt;BR /&gt; i=0;&lt;BR /&gt; (void) enqueueEvent( mainEventQueue, ADC_MEASUREMENT_AVAILABLE, (invisible_event_params_t) { .uIntVal = avgAdc16ConvValue }, event_batt_measurement_available );&lt;BR /&gt; }&lt;BR /&gt; else{&lt;BR /&gt; read_battery_level();&lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;=====================&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Gaurav.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Sep 2017 07:23:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Inconsistency-of-ADC-Conversion-value/m-p/708985#M43502</guid>
      <dc:creator>gauravbanyal</dc:creator>
      <dc:date>2017-09-20T07:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: Inconsistency of ADC Conversion value</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Inconsistency-of-ADC-Conversion-value/m-p/708986#M43503</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Gaurav,&lt;/P&gt;&lt;P&gt;Have you connect a capacitor to the ground on VREF_OUT pin?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jing&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Sep 2017 08:27:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Inconsistency-of-ADC-Conversion-value/m-p/708986#M43503</guid>
      <dc:creator>jingpan</dc:creator>
      <dc:date>2017-09-21T08:27:48Z</dc:date>
    </item>
    <item>
      <title>Re: Inconsistency of ADC Conversion value</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Inconsistency-of-ADC-Conversion-value/m-p/708987#M43504</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using the internal reference voltage for the ADC. So I understand I cannot connect the capacitor to any pin on the microcontroller as you have suggested?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;best regards,&lt;/P&gt;&lt;P&gt;Gaurav&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Sep 2017 08:31:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Inconsistency-of-ADC-Conversion-value/m-p/708987#M43504</guid>
      <dc:creator>gauravbanyal</dc:creator>
      <dc:date>2017-09-21T08:31:49Z</dc:date>
    </item>
    <item>
      <title>Re: Inconsistency of ADC Conversion value</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Inconsistency-of-ADC-Conversion-value/m-p/708988#M43505</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Gaurav,&lt;/P&gt;&lt;P&gt;The ADC can be configured to accept one of the two voltage reference pairs as the reference voltage (VREFSH and VREFSL) used for conversions. The two pairs are external (VREFH and VREFL) and alternate (VALTH and VALTL).&lt;/P&gt;&lt;P&gt;So I think your internal reference means VALTH and VALTL.&lt;/P&gt;&lt;P&gt;In KL03 VREF_OUT connected as the VALT reference. You can find the descriptions in page 381 in the reference manual.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jing&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Sep 2017 08:49:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Inconsistency-of-ADC-Conversion-value/m-p/708988#M43505</guid>
      <dc:creator>jingpan</dc:creator>
      <dc:date>2017-09-21T08:49:18Z</dc:date>
    </item>
  </channel>
</rss>

