AnsweredAssumed Answered

Unable to read multiple adc channel readings

Question asked by Rahul PS on Aug 12, 2015
Latest reply on Aug 13, 2015 by Rahul PS

We are using FRDM K64F evaluation board.

Using KDS 3.0.0 and KSDK 1.2.0. Using MQXRTOS in KSDK

 

 

In our project,i want to read multiple adc channels.

Using the pins PTB2,PTB3(ADC0) and PTB10,PTB11(ADC1).

But currently i can only read PTB2 & PTB10 values, ie single channels from each modules.

 

we are blocked in this

Can any one help me to solve this problem.

 

configuration codes are copied below:::::::::::::::::::::::::::::::::::::::

 

configuration for adc0(therm1):

 

const adc16_converter_config_t therm1_InitConfig0 = {

  .lowPowerEnable = false,

  .clkDividerMode = kAdc16ClkDividerOf1,

  .longSampleTimeEnable = false,

  .resolution = kAdc16ResolutionBitOfSingleEndAs12,

  .clkSrc = kAdc16ClkSrcOfBusClk,

  .asyncClkEnable = false,

  .highSpeedEnable = false,

  .longSampleCycleMode = kAdc16LongSampleCycleOf24,

  .hwTriggerEnable = false,

  .refVoltSrc = kAdc16RefVoltSrcOfVref,

  .continuousConvEnable = true,

  .dmaEnable = false,

};

 

const adc16_converter_config_t therm1_InitConfig1 = {

  .lowPowerEnable = false,

  .clkDividerMode = kAdc16ClkDividerOf1,

  .longSampleTimeEnable = false,

  .resolution = kAdc16ResolutionBitOfSingleEndAs8,

  .clkSrc = kAdc16ClkSrcOfBusClk,

  .asyncClkEnable = false,

  .highSpeedEnable = false,

  .longSampleCycleMode = kAdc16LongSampleCycleOf24,

  .hwTriggerEnable = false,

  .refVoltSrc = kAdc16RefVoltSrcOfVref,

  .continuousConvEnable = true,

  .dmaEnable = false,

};

 

 

const adc16_hw_cmp_config_t therm1_HwConfig0 = {

};

 

const adc16_chn_config_t therm1_ChnConfig1 = {

  .chnIdx = kAdc16Chn13,

  .convCompletedIntEnable = false,

  .diffConvEnable = false

};

const adc16_chn_config_t therm1_ChnConfig0 = {

  .chnIdx = kAdc16Chn12,

  .convCompletedIntEnable = false,

  .diffConvEnable = false

};

/* END therm1. */

 

 

configuration for adc1 module(universal)

 

const adc16_converter_config_t universal_InitConfig0 = {

  .lowPowerEnable = false,

  .clkDividerMode = kAdc16ClkDividerOf1,

  .longSampleTimeEnable = false,

  .resolution = kAdc16ResolutionBitOfSingleEndAs12,

  .clkSrc = kAdc16ClkSrcOfBusClk,

  .asyncClkEnable = false,

  .highSpeedEnable = false,

  .longSampleCycleMode = kAdc16LongSampleCycleOf24,

  .hwTriggerEnable = false,

  .refVoltSrc = kAdc16RefVoltSrcOfVref,

  .continuousConvEnable = true,

  .dmaEnable = false,

};

 

const adc16_converter_config_t universal_InitConfig1 = {

  .lowPowerEnable = false,

  .clkDividerMode = kAdc16ClkDividerOf1,

  .longSampleTimeEnable = false,

  .resolution = kAdc16ResolutionBitOfSingleEndAs12,

  .clkSrc = kAdc16ClkSrcOfBusClk,

  .asyncClkEnable = false,

  .highSpeedEnable = false,

  .longSampleCycleMode = kAdc16LongSampleCycleOf24,

  .hwTriggerEnable = false,

  .refVoltSrc = kAdc16RefVoltSrcOfVref,

  .continuousConvEnable = true,

  .dmaEnable = false,

};

 

const adc16_chn_config_t universal_ChnConfig0 = {

  .chnIdx = kAdc16Chn14,

  .convCompletedIntEnable = false,

  .diffConvEnable = false

};

const adc16_chn_config_t universal_ChnConfig1 = {

  .chnIdx = kAdc16Chn15,

  .convCompletedIntEnable = false,

  .diffConvEnable = false

};

/* END universal. */

 

 

 

task1()

 

while(1)

  {

  //Read Analog Inputs

  ADC16_DRV_ConfigConvChn(FSL_THERM1,1,&therm1_ChnConfig0);

  ADC16_DRV_WaitConvDone(FSL_THERM1,0);

  value1=ADC16_DRV_GetConvValueSigned(FSL_THERM1,0);

  PRINTF("ADC1 value is %d\n",value1);

 

  ADC16_DRV_ConfigConvChn(FSL_THERM1,1,&therm1_ChnConfig1);

  DelayFunction ();

  ADC16_DRV_WaitConvDone(FSL_THERM1,1);

  value2=ADC16_DRV_GetConvValueSigned(FSL_THERM1,1);

  PRINTF("ADC2 value is %d\n",value2);

 

  ADC16_DRV_ConfigConvChn(FSL_UNIVERSAL,1,&universal_ChnConfig0);

  ADC16_DRV_WaitConvDone(FSL_UNIVERSAL,0);

  value3=ADC16_DRV_GetConvValueSigned(FSL_UNIVERSAL,0);

  PRINTF("ADC3 value is %d\n",value3);

 

  ADC16_DRV_ConfigConvChn(FSL_UNIVERSAL,1,&universal_ChnConfig1);

  DelayFunction ();

  ADC16_DRV_WaitConvDone(FSL_UNIVERSAL,1);

  value4=ADC16_DRV_GetConvValueSigned(FSL_UNIVERSAL,1);

  PRINTF("ADC4 value is %d\n",value4);

 

  }

 

 

What may be the fault in this procedure................Waiting for a solution asap..

 

 

 

Thanks

RAHUL

Outcomes