Periodical ADC offset jumps on Kinetis K02

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Periodical ADC offset jumps on Kinetis K02

626件の閲覧回数
adriankeil
Contributor I

Hello,

I'm using the MK02FN64VLH10 for a temperature regualtion and I get weird jumps in the ADC-value. The ADC-value periodically jumps up and down about 600 lsb. It is not a peak but a permanent offset! The time in between these jumps is about 11h.

I also measured the voltage on the ADC externally and it's perfectly stable.

The ADC is configured using Processor Expert and Hardware Average is enabled. Every ms the COCO-bit is checked and if the ADC has finished the value is read (see code below).

Core Clock is 80MHz, Bus Clock is 40MHz.

It's also worth mentioning that the problem does not always appear. Sometimes it works just fine and after a reboot the problem starts to occur.

Does anyone has an idea by what this could be caused?

In adConv1.c:

const adc16_converter_config_t adConv1_InitConfig0 = {
  .lowPowerEnable = false,
  .clkDividerMode = kAdc16ClkDividerOf8,
  .longSampleTimeEnable = true,
  .resolution = kAdc16ResolutionBitOf16,
  .clkSrc = kAdc16ClkSrcOfBusClk,
  .asyncClkEnable = false,
  .highSpeedEnable = false,
  .longSampleCycleMode = kAdc16LongSampleCycleOf24,
  .hwTriggerEnable = false,
  .refVoltSrc = kAdc16RefVoltSrcOfValt,
  .continuousConvEnable = false,
  .dmaEnable = false,
};

const adc16_hw_average_config_t adcAverageConfig = {
   .hwAverageEnable = true,
   .hwAverageCountMode = kAdc16HwAverageCountOf32,
};

In main.c:

ADC16_DRV_ConfigHwAverage(FSL_ADCONV1,&adcAverageConfig);

ADC16_DRV_ConfigConvChn(FSL_ADCONV1,0,&TemperatureB);

for(;;)

{

   if(f1ms>=1)
   {
      f1ms = 0;
      ADC_Type * base = g_adcBase[FSL_ADCONV1];
      if ( ADC16_HAL_GetChnConvCompletedFlag(base, 0) )
      {
         gAdcValue = ADC16_DRV_GetConvValueRAW(FSL_ADCONV1,0);
         ADC16_DRV_ConfigConvChn(FSL_ADCONV1,0,&TemperatureB);
      }

   }

   //Rest of the code which has nothing to do with th ADC...

}

However the periodic time seems to be dependant on the ADC-configuration. When I configured it to collect ADC-values much faster the periodic time was just 20min (no Hardware Average, rest of main as above):

const adc16_converter_config_t adConv1_InitConfig0 = {
  .lowPowerEnable = false,
  .clkDividerMode = kAdc16ClkDividerOf1,
  .longSampleTimeEnable = false,
  .resolution = kAdc16ResolutionBitOf16,
  .clkSrc = kAdc16ClkSrcOfAsynClk,
  .asyncClkEnable = false,
  .highSpeedEnable = true,
  .longSampleCycleMode = kAdc16LongSampleCycleOf4,
  .hwTriggerEnable = false,
  .refVoltSrc = kAdc16RefVoltSrcOfValt,
  .continuousConvEnable = false,
  .dmaEnable = false,
};

ラベル(1)
0 件の賞賛
2 返答(返信)

483件の閲覧回数
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Adrian,

How about using the following code, in the code, the ADC is launched to convert, then wait by checking if the COCO bit is set.

I can not make sure if it is okay, anyway, pls have a try.

BR

Xiangjun Rong

In main.c:

ADC16_DRV_ConfigHwAverage(FSL_ADCONV1,&adcAverageConfig);

ADC16_DRV_ConfigConvChn(FSL_ADCONV1,0,&TemperatureB);

for(;;)

{

   if(f1ms>=1)
   {
      f1ms = 0;

      ADC16_DRV_ConfigConvChn(FSL_ADCONV1,0,&TemperatureB);
      ADC_Type * base = g_adcBase[FSL_ADCONV1];
      while(! ADC16_HAL_GetChnConvCompletedFlag(base, 0) ) {}

      //{
         gAdcValue = ADC16_DRV_GetConvValueRAW(FSL_ADCONV1,0);
    
      //}

   }

   //Rest of the code which has nothing to do with th ADC...

}

0 件の賞賛

483件の閲覧回数
adriankeil
Contributor I

Hi Xiangjun,

thanks for your support! I tried your suggestion along with a lot of other things but nothing helped. So I went back to the hardware and could finally trace it back to an issue with electromagnetic radiation. My initial instrument wasn't fast enough to show that... I fixed it in hardware now :smileyhappy:

Best regards

Adrian

0 件の賞賛