AnsweredAssumed Answered

MKL17 16 bit ADC Configuration

Question asked by whata on Feb 2, 2018
Latest reply on Feb 6, 2018 by Robin_Shen

Hi,

 

I'm attempting to configure MKL17Z256VLH4 to sample two channels (PTB1 ADC0_SE9 and PTB2 ADC0_SE12) with 16 bit resolution, single-ended, however, after configuration the maximum result I get is around 12-bit (4093 adc counts while measuring 3.3V source), my configuration is as follows:

 

     /* Configure Bus Voltage Channel */
     busVoltageChnCfg.channelNumber = 12;
     busVoltageChnCfg.enableDifferentialConversion = false;
     busVoltageChnCfg.enableInterruptOnConversionCompleted = false;

     /* Configure Bus Current Channel */
     busCurrentChnCfg.channelNumber = 9;
     busCurrentChnCfg.enableDifferentialConversion = false;
     busCurrentChnCfg.enableInterruptOnConversionCompleted = false;

     adc16Config.referenceVoltageSource = kADC16_ReferenceVoltageSourceVref;
     adc16Config.enableLowPower = false;
     adc16Config.longSampleMode = kADC16_LongSampleCycle24;
     adc16Config.resolution = kADC16_Resolution16Bit;

     ADC16_GetDefaultConfig(&adc16Config);
     ADC16_Init (ADC0, &adc16Config);
     ADC16_EnableHardwareTrigger(ADC0, false);
     ADC16_SetHardwareAverage(ADC0, kADC16_HardwareAverageCount32);

 

And I convert by calling the following

 

     ADC16_SetChannelConfig(ADC0, 0, &busVoltageChnCfg);
     while ((kADC16_ChannelConversionDoneFlag &
               ADC16_GetChannelStatusFlags(ADC0, 0)) == 0)
     {

     }

     PRINTF("ADC    : Bus Voltage: %d.\r\n",
               ADC16_GetChannelConversionValue(ADC0, 0));


     ADC16_SetChannelConfig(ADC0, 0, &busCurrentChnCfg);
     while ((kADC16_ChannelConversionDoneFlag &
               ADC16_GetChannelStatusFlags(ADC0, 0)) == 0)
     {

     }

     PRINTF("ADC    : Bus Current: %d.\r\n",
               ADC16_GetChannelConversionValue(ADC0, 0));

Outcomes