ADC calibration

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ADC calibration

1,050 Views
Kewal
Contributor IV

I am trying to read the voltage level of 12V and 3.3V and I am not sure where I am going wrong,... There is a 3V VRefH and VRefL is GND.

 

ADC16_DRV_StructInitUserConfigDefault(&adcUserConfig);

 

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;

#if FSL_FEATURE_ADC16_HAS_DIFF_MODE

    chnConfig.diffConvEnable = false;

#endif

    chnConfig.convCompletedIntEnable  = false;

 

 

    // Software trigger the conversion.

    ADC16_DRV_ConfigConvChn(ADC16_INSTANCE, ADC16_CHN_GROUP, &chnConfig);

 

 

    // Wait for the conversion to be done.

    ADC16_DRV_WaitConvDone(ADC16_INSTANCE, ADC16_CHN_GROUP);

 

 

    adcValue = 0;

    // Fetch the conversion value.

    adcValue = ADC16_DRV_GetConvValueSigned(ADC16_INSTANCE, ADC16_CHN_GROUP);

 

     double voltage;

    voltage = (int)(adcValue * 0.00000000069849);

 

 

 

I am not able to correctly read the adcValue, Is there something which I need to calibrate to get the correct ADC readings.

Labels (1)
0 Kudos
Reply
2 Replies

751 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Kewal,

Before answer your question, I was wondering if you can tell me which MCU you select and what kind of result you got.

I'm looking forward to your reply.
Have a great day,
Ping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

751 Views
Kewal
Contributor IV

by the way that was a mistake i pasted

voltage = (int)(adcValue * 0.00000000069849);

Actually, I am trying to convert using

voltage = (double) (adcValue * (3/65535)));

0 Kudos
Reply