Can't read analog I/P through FRDM-KW40Z's ADC in terminal window


I’ve a piezoelectric sensor and I have it hooked to the header J25 pin 8. The board (FRDM-KW40Z) is usb powered. I’m using the adc16 demo code (from nxp) and trying to structure around it.

The adc demo script writes temperature to the terminal windwow, based on that, I’m trying to access another available channel and read the voltage responses of my analog sensor.


ADC16_DRV_Init(ADC16_INSTANCE, &adcUserConfig); 

adc16_chn_config_t chnConfig;

    // Configure the conversion channel

    // differential and interrupt mode disable.

chnConfig.chnIdx     = (adc16_chn_t)ADC16_VM12;


    chnConfig.diffConvEnable = false;


    chnConfig.convCompletedIntEnable  = false; 

    // Software trigger the conversion.

    ADC16_DRV_ConfigConvChn(ADC16_INSTANCE, ADC16_CHN_GROUP, &chnConfig); 

    // Wait for the conversion to be done.


    adcValue = 0;

    // Fetch the conversion value.

    adcValue = ADC16_DRV_GetConvValueSigned(ADC16_INSTANCE, ADC16_CHN_GROUP); 

    double voltage;

    voltage = (int)(adcValue * 0.00000195312);

    return voltage;

I think chnConfig.chnIdx = (adc16_chn_t)ADC16_TEMPERATURE_CHN; is where the ADC is being configure for Channel. I tried to ‘duplicate’ this function and change in the altered one; define ADC16_TEMPERATURE_CHN to different channel. “calibrateParams” this function read from a different channel , but it reads only once, so it’s no good.

Please, advice of any possible errors that I’ve made and also possible methods to accomplish analog measurement with the adc. This board is a handful and I’m having a hard time trying to an adc channel for analog measurement! Any advice is much appreciated. Thank you. Good day.