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.
Hi Kaival,
The steps you followed are correct. However, if you check ADC_ConversionResult2Mv API needs your reference value.
In ADC_basic example that value is assigned with the following function.
This function multiplies the reference value as follows (1.5*reference):
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!
-----------------------------------------------------------------------------------------------------------------------
I have the same problem, but I didn't know where should I change and multiply.
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
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?
Hi Ashkan,
Please try to use the value of your external reference voltage instead of g_AdcBandgap.
Best regards,
Felipe
I think I made a big mistake.
First of all, should I connect my reference voltage to pin PA07? or Vin?
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.
3. For ADC_ConversionResult2Mv you will have to insert your reference value manually as is described in my previous replay.
Best regards,
Felipe
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);
Hi Ashkan,
I think you are overwriting adcSdConfigStruct with the default configuration.
Please try to execute adcSdConfigStruct.vinnSelect = kADC_VinnSelectVref; after the default configuration call.
Best regards,
Felipe
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.
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