QN9080 ADC External Vref

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

QN9080 ADC External Vref

2,489 Views
kaival_shah
Contributor II

I am using qn908xcdk_wireless_examples_bluetooth_wireless_uart_freertos demo code for my development. In my application, I want to use External Vref @PA07. An external voltage is 3.3.

The demo application is configured as 1.2 V bandgap. I changed the following parameters 

adcConfigStruct.refSource = kADC_RefSourceExtWithDriver; ---> In ADC_Init conifguration

adcSdConfigStruct.vinnSelect = kADC_VinnSelectVref; --> In ADC_SetSdConfig configuration

Do I need to do anything else? When I use 1.2 Internal application is giving proper ADC output through ADC_ConversionResult2Mv. But if I use PA07 then I am not getting proper output through ADC_ConversionResult2Mv API.

Labels (1)
11 Replies

1,933 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi Kaival,

The steps you followed are correct. However, if you check ADC_ConversionResult2Mv API needs your reference value.

pastedImage_13.png

In ADC_basic example that value is assigned with the following function.

pastedImage_14.png

This function multiplies the reference value as follows (1.5*reference):

pastedImage_15.png

If you multiply your external reference value by 1.5 and put it in the ADC_ConversionResult2Mv API, you should get the correct mv value from the ADC.

I hope this helps.

Best regards, 

Felipe

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

1,933 Views
ashkanrezaee
Contributor III

I have the same problem, but I didn't know where should I change and multiply. 

0 Kudos
Reply

1,933 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi Ashkan,

In function ADC_ConversionResult2Mv, instead of using g_AdcBandgap as parameter for the reference voltage you are going to use the following:

        fresult = ADC_ConversionResult2Mv(DEMO_ADC_BASE, DEMO_ADC_CHANNEL, DEMO_ADC_CFG_IDX, YourReferenceVoltage*1.5, g_AdcVinn,
                                          adcConvResult);‍‍

Best regards,

Felipe

0 Kudos
Reply

1,933 Views
ashkanrezaee
Contributor III
        fresult = ADC_ConversionResult2Mv(DEMO_ADC_BASE, DEMO_ADC_CHANNEL, DEMO_ADC_CFG_IDX, g_AdcBandgap*1.5, g_AdcVinn,
                                          adcConvResult);


When I put these parameters I do not get correct values but when I multiply "g_AdcBandgap" by 2.5 I get correct values! where is my problem?

0 Kudos
Reply

1,933 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi Ashkan,

Please try to use the value of your external reference voltage instead of g_AdcBandgap.

Best regards,

Felipe

0 Kudos
Reply

1,933 Views
ashkanrezaee
Contributor III

I think I made a big mistake.
First of all, should I connect my reference voltage to pin PA07? or Vin?

Secondly, how can I read the reference voltage from PA07?
third, how can I put my reference voltage into the conversion instead of g_AdcBandgap?
0 Kudos
Reply

1,933 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi Ashkan,

Please see my answers below:

1. PA07

2. You actually don't need to read it. Just make sure you configure it correctly in adc_config_t.

pastedImage_1.png

3. For ADC_ConversionResult2Mv you will have to insert your reference value manually as is described in my previous replay.

Best regards,

Felipe

0 Kudos
Reply

1,933 Views
ashkanrezaee
Contributor III

Ok, so what I did was correct. however, when I put "3.3*1.5" instead of "g_AdcBandgap", the result is not correct and it is always higher than real values. Why?

 

This is my ADC configuration:

 

ADC_GetDefaultConfig(&adcConfigStruct);
adcConfigStruct.channelEnable = (1U << DEMO_ADC_CHANNEL);
adcConfigStruct.channelConfig = (DEMO_ADC_CFG_IDX << DEMO_ADC_CHANNEL);
adcConfigStruct.triggerSource = DEMO_ADC_TRIGGER;
adcConfigStruct.convMode = kADC_ConvModeSingle;
adcConfigStruct.refSource = kADC_RefSourceExtWithDriver;
ADC_Init(DEMO_ADC_BASE, &adcConfigStruct);

 

/* Initial ADC Sigma Delta(SD) configuration */
adcSdConfigStruct.vinnSelect = kADC_VinnSelectVref;
ADC_GetSdDefaultConfig(&adcSdConfigStruct);
ADC_SetSdConfig(DEMO_ADC_BASE, DEMO_ADC_CFG_IDX, &adcSdConfigStruct);

 

And this is my conversion:

fresult = ADC_ConversionResult2Mv(DEMO_ADC_BASE, DEMO_ADC_CHANNEL, DEMO_ADC_CFG_IDX, 3.3*1.5, g_AdcVinn,
                                                            adcConvResult);

0 Kudos
Reply

1,933 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi Ashkan,

I think you are overwriting adcSdConfigStruct with the default configuration.

pastedImage_2.png

Please try to execute adcSdConfigStruct.vinnSelect = kADC_VinnSelectVref; after the default configuration call.

Best regards,

Felipe

1,933 Views
ashkanrezaee
Contributor III

Hi Felipe,

When I changed the ADCs reference, the measured data which are shown by ADCs are not stable. Do you know why? I connected 3.3V to pin PA07 and changed all of the configurations. My values changed around 1 or 2 mV but it is important to be stable.

0 Kudos
Reply

1,933 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi Ashkan,

This is due to ADC accuracy. However, many factors can be causing this, voltage reference, PCB layout, analog source impedance, temperature. ADC accuracy will depend on the application.

Best regards,

Felipe

0 Kudos
Reply