AnsweredAssumed Answered

I am trying to test C functionality on FRDM-K22F board. I am not getting results as expected.

Question asked by Snehal Patil on Mar 24, 2016
Latest reply on Apr 5, 2016 by xiangjun.rong

I am not getting correct ADC count. I am trying to give input to ADC0_DP0 and ADC0_DM0 in differential mode.for this I kept settings as:

 

init_adc(void)

 

adc16_converter_config_t userConvConfig;


/* Un-gate port clock*/


//Enable Port E clock


/* Set current pin as analog pin:ADC.*/  //MK02FN128VFM10 pin settings.this needs to be uncommented.


/* PORT_HAL_SetMuxMode(PORTE, 16, kPortPinDisabled); //PTE16

 

// Execute the auto-calibration.


lowPowerEnable = false;

 

clkDividerMode = kAdc16ClkDividerOf4//check clock settings then decide


longSampleTimeEnable = false;

 

//userConvConfig.resolution = kAdc16ResolutionBitOfDiffModeAs13;


clkSrc = kAdc16ClkSrcOfBusClk;

 

asyncClkEnable = false;

 

highSpeedEnable = false;

 

longSampleCycleMode = kAdc16LongSampleCycleOf24;

 

hwTriggerEnable = false;

 

refVoltSrc = kAdc16RefVoltSrcOfVref;//kAdc16RefVoltSrcOfValt;//


continuousConvEnable = true;

 

resolution = kAdc16ResolutionBitOf16;//kAdc16ResolutionBitOf16;


FSL_FEATURE_ADC16_HAS_DMA

 

dmaEnable = false;


/* FSL_FEATURE_ADC16_HAS_DMA */


#if (FSL_FEATURE_ADC16_MAX_RESOLUTION >= 16)

 

// userConvConfig.resolution = kAdc16ResolutionBitOfDiffModeAs16;//kAdc16ResolutionBitOf16;


#endif


bushing_voltage(void)

 

adc16_chn_config_t chnConfig;

 

uint16_t i=0;

 

// Configure the conversion channel


// differential and interrupt mode disable.


chnIdx     = kAdc16Chn0d;

 

#if FSL_FEATURE_ADC16_HAS_DIFF_MODE

 

diffConvEnable = true;

 

#endif


convCompletedIntEnable  = false;

 

// Software trigger the conversion.


// Wait for the conversion to be done.


kAdcChnConvCompleteFlag);

 

if (conv_done == true)

 

// Fetch the conversion value.


uint16_t)ADC16_DRV_GetConvValueRAW(ADC16_INSTANCE, ADC16_CHN_GROUP);

 

//   int_adc_val = (int16_t) ADC16_DRV_GetConvValueSigned(ADC16_INSTANCE, ADC16_CHN_GROUP);

}

 

I tried this giving DC power supply: 1.for Vref and 2nd DC power supply for differential channels;

Vref = 3 V

Differential input = 2.5V

But I am not getting correct results.

Please verify whether I am on correct path in above code (ADC settings and channel configuration) and connections given below

Connection pins:

VrefH=3V to pin 16 on J2 connector

VrefL is internally connected to gnd as FRDM-K22F schematic.

Pin 1 of J24 to ADC0_DP0 and 3 to ADC0_DM0

Connected DC power supply -ve terminal to GND pin 12 of J25.

Request to help as soon as possible.

Outcomes