When I use internal voltage reference my ADC bounces.

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

When I use internal voltage reference my ADC bounces.

2,331 次查看
josephgundel
Contributor III

When I configure my K02 to use internal voltage reference I have a really noisy ADC. It can vary 100 on each reading. I have it configured for 12 bit.

Here is my Internal reference configuration.

BW_VREF_SC_VREFEN(VREF_BASE, 1U)

BW_VREF_SC_MODE_LV(VREF_BASE, 1U)

BW_VREF_SC_ICOMPEN(VREF_BASE, 1U)

BW_VREF_SC_REGEN(VREF_BASE,1U)

Here is my ADC configuration.

//ADC Config for all channels

adc16_user_config_t adcUserConfig = {

        .intEnable = false,

        .lowPowerEnable = false,

        .clkDividerMode = kAdcClkDividerInputOf8,

        .resolutionMode = kAdcResolutionBitOfSingleEndAs12,

        .clkSrcMode = kAdcClkSrcOfBusClk,

        .asyncClkEnable = false,

        .highSpeedEnable = true,

        .hwTriggerEnable = false,

        .dmaEnable = false,

        .refVoltSrcMode=   //kAdcRefVoltSrcOfVref,

                kAdcRefVoltSrcOfValt,

        .continuousConvEnable =false

};

Please Help!

I need to use the internal reference voltage

标签 (1)
标记 (3)
0 项奖励
回复
9 回复数

1,750 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Joseph,

Can you test the voltage of VREF_OUT pin? I suspect that the VREF module setting is incorrect.

Can you use the following code to set the Vref module?

VREF_SC=0xc0;

    while(!(VREF_SC&VREF_SC_VREFST_MASK)) {}

    VREF_SC=0xc2;

    asm("nop"); //set a break point here and test the VREF_OUT pin, on the TWR_K60D100M, T1 pad

Hope it can help you.

BR

XiangJun Rong

0 项奖励
回复

1,750 次查看
josephgundel
Contributor III

This did not work. I cannot test the VREF_OUT pin because I am using the k2 32 pin package that does not have this pin broken out. I am trying to use this internal reference for the ADC. This did not help it is still very noisy.

0 项奖励
回复

1,750 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Joseph,

If you connect the ADC analog pin to  analog GND, is there much noise(I means that the ADC samples vary as you said)? The analog pin must be driven by a low impedance analog source. You can not float the analog pin to have a test.

If you still have noise, pls share your code so that I can test on my board, pls tell us the software tools and the part number of the processor.

BR

XiangJun Rong

0 项奖励
回复

1,750 次查看
josephgundel
Contributor III

I do have the analog pin connected to ground.

I am using the MK02FN64VFM10 32pin package

I am doing the following to configure the internal VREF.

  VREF_SC = 0xc0;

    while(!(VREF_SC&VREF_SC_VREFST_MASK))

    {};

    VREF_SC=0xc2;

I configure the adc by:

adc16_user_config_t adcUserConfig = {

        .intEnable = false,

        .lowPowerEnable = true,//false,

        .clkDividerMode = kAdcClkDividerInputOf8,

        .resolutionMode = kAdcResolutionBitOfSingleEndAs12,

        .clkSrcMode =  kAdcClkSrcOfBusClk,

        .asyncClkEnable = false,

        .highSpeedEnable = true,

        .hwTriggerEnable = false,

        .dmaEnable = false,

        .refVoltSrcMode=  kAdcRefVoltSrcOfValt,

        .continuousConvEnable =false

};

adc16_status_t status = ADC16_DRV_Init(ADC_INST, &adcUserConfig);

I read the adc by:

  for(int i =0; i < ADC_TABLE_COUNT; i++)

    {

        U16 id = read_ADC_raw_value(i);

        //id = (id * 1700 / 4096);

        printf("ADC Table %d ->%d \n",i , id);

    }

0 项奖励
回复

1,750 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Joseph,

Frankly speaking, I do not think your following code is correct:

  for(int i =0; i < ADC_TABLE_COUNT; i++)

    {

        U16 id = read_ADC_raw_value(i);

        //id = (id * 1700 / 4096);

        printf("ADC Table %d ->%d \n",i , id);

    }

As you know, before you call read_ADC_raw_value(i);, you have to know the ADC conversion is over. It is okay to call the read_ADC_raw_value(i); in ISR of ADC conversion completion. But if you call the read_ADC_raw_value(i); in main(), you have to start ADC conversion, then check the ADC status register to guarantee the conversion is over, and read ADC result.

Hope it can help you

Pls check the body of the read_ADC_raw_value(i); function to check if it polls the ADC status register.

BR

Xiangjun Rong

0 项奖励
回复

1,750 次查看
josephgundel
Contributor III

That read_ADC_raw_value is a function I wrote. It handles averaging 16 samples and it does wait until conversion is done. Here it is:

U16 read_ADC_raw_value(adc_channel_t channel)

{

    U16 val = 0;

    switch(channel)    {

    case red_return:

    case green_return:

    case blue_return:

    case white_return:

    case light_id:

    case flyback_temp:

    case vbus:

    case led_temp:

       for (int i = 0; i < 16; i++)    //Average of 16 samples

        {

             ADC16_DRV_ConfigConvChn(ADC_INST, 0U, &adcChnConfig[channel]);

            ADC16_DRV_WaitConvDone(ADC_INST, 0U);

            val += ADC16_DRV_GetConvValueRAW(ADC_INST, 0U);

       }

        val >>= 4;

        break;

    }

    return val;

}

0 项奖励
回复

1,750 次查看
superhuat
Contributor I

Hi Joseph

Have you solve the issue? I'm also using the same chip as you. MK02FN64VFM10. I using ext Vref by connecting Vdd to pin 7 in which connected to gnd via a 100nF cap. The ADC result that I got are not usable as the noise is too high, in range of hundreds. Tried ways n mean and different ADC configurations but to no avail.

Best Regards

Soon Huat

0 项奖励
回复

1,750 次查看
josephgundel
Contributor III

Turns out this package does not have an internal Voltage reference!.

Have to use the external.

0 项奖励
回复

1,750 次查看
superhuat
Contributor I

yup, I'm using ext vref, but my adc result are very noisy. How about yours? Have you gotten some good adc results?

Thanks.

0 项奖励
回复