⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.wsdof.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
11 posts / 0 new
Last post
DavidW
Offline
Last seen:2 years 4 months ago
Joined:2017-11-17 08:35
adc measurement of channel P03 wrong

Hello Support,

i have a problem with the adc Channel P03.
The measurements of the adc Channels P00, P01, P02 work fine, but with the Channel P03 i always get one wrong value.
The board i use is the DK-Basic-Kit with Da14580.

Here is my code:
//ADC configuration
#define GPIO_ADC1_PORT GPIO_PORT_0
#define GPIO_ADC1_PIN GPIO_PIN_1
#define GPIO_ADC0_PORT GPIO_PORT_0
#define GPIO_ADC0_PIN GPIO_PIN_0
#define GPIO_ADC2_PORT GPIO_PORT_0
#define GPIO_ADC2_PIN GPIO_PIN_2
#define GPIO_ADC3_PORT GPIO_PORT_0
#define GPIO_ADC3_PIN GPIO_PIN_3

RESERVE_GPIO(ADC_PIN1, GPIO_ADC1_PORT, GPIO_ADC1_PIN, PID_ADC);
RESERVE_GPIO(ADC_PIN0, GPIO_ADC0_PORT, GPIO_ADC0_PIN, PID_ADC);
RESERVE_GPIO(ADC_PIN2, GPIO_ADC2_PORT, GPIO_ADC2_PIN, PID_ADC);
RESERVE_GPIO(ADC_PIN3, GPIO_ADC3_PORT, GPIO_ADC3_PIN, PID_ADC);

GPIO_ConfigurePin(GPIO_ADC1_PORT,GPIO_ADC1_PIN, INPUT, PID_ADC, false);
GPIO_ConfigurePin(GPIO_ADC0_PORT,GPIO_ADC0_PIN, INPUT, PID_ADC, false);
GPIO_ConfigurePin(GPIO_ADC2_PORT,GPIO_ADC2_PIN, INPUT, PID_ADC, false);
GPIO_ConfigurePin(GPIO_ADC3_PORT,GPIO_ADC3_PIN, INPUT, PID_ADC, false);

//function of adc sample
uint16_t adc_read_P03_channel(void)
{

uint16_t adc_sample, adc_sample2;

adc_init(GP_ADC_SE, 0, GP_ADC_ATTN3X);

adc_enable_channel(ADC_CHANNEL_P03 );

adc_sample = adc_get_sample();

adc_init(GP_ADC_SE, 0, GP_ADC_ATTN3X);

adc_enable_channel(ADC_CHANNEL_P03 );

adc_sample2 = adc_get_sample();
adc_sample = (adc_sample2 + adc_sample);
adc_disable();

return adc_sample
}

Regards
David

Keywords:
ADC
Device:
LC_Dialog
Offline
Last seen:3 weeks 4 days ago
Staff
Joined:2016-09-19 23:20
Hi David,

Hi David,

I have tried the same implementation on my side and I am getting the appropriate values on a Basic DK. All I did differently was to print the values read and also I am calling this function during theapp_validate_sleepcallback to test the function repeatedly.

Maybe you can try callibrating the ADC during the bootup config step or may be add some delay after theadc_initlike it was done inadc_get_vbat_sample. See if you get better results.

Note: Also, I have noticed in your code that you returning the samples added but not divided by 2. Just wanted to raise this if that is not what you intended to do.

Please let me know if you are still having the issue and may be some more insights into the problem.

Best,
LC_Dialog

DavidW
Offline
Last seen:2 years 4 months ago
Joined:2017-11-17 08:35
Thanks for the quick response

Thanks for the quick response.

I tried everything and it didn't work.
It doesn't matter if i take a measurement of 1V or 3V on P03, The adc shows one random value, but its always about the same range. I check the voltage of the pin without signal and i get 0V, so there is no offset.
The other channels work with my implementation,, so i think the conversation or the configuration of channel P03 is wrong.

I changed the code of the ble pheripheral example.
Is there any Configuration on this Pin, that i don't know?

Thank you for that advise.
You're right that i don't divide after the addition, but i has no affect of the wrong Channel.

Regards
David

LC_Dialog
Offline
Last seen:3 weeks 4 days ago
Staff
Joined:2016-09-19 23:20
Hi David,

Hi David,

I will look for more possible issues here. However, could you try and use theEmpty_Peripheral_Templateproject and test this implementation. This project is free from all the unnecessary operations that might sometimes interfere and take priority.

还有,你是怎么调用这个函数。是function being called repeatedly or just once at some point during or after bootup.

Best,
LC_Dialogg

DavidW
Offline
Last seen:2 years 4 months ago
Joined:2017-11-17 08:35
Hi LC,

Hi LC,

我修改了bie pheripheral例子dc measurement and send it to the Computer via BLE. I use the function app_adcvall_timer_cb_handler like in the example to send the value every second.

I tested the adc with all channels on the empty pheripheral template & additionally with a modified battery example with Uart as output.
Its always the same result.
Channel P00, P01, P02 shows the right value ( 1V, 2V, 3V), but Channel P03 shows alway the same one value (in binary format: 1110001100). The value varies about the last two bits. so the measurement on P03 occurs.
I also checked the contact from the pin P03 to the chip, everything okay.

Is it possible that this channel has any damage in the inside of the chip?

Best regards,
David

LC_Dialog
Offline
Last seen:3 weeks 4 days ago
Staff
Joined:2016-09-19 23:20
Hi David,

Hi David,

This is very strange that only the Channel P03 is showing wierd behavior. We haven't seen any such issue on the ADC on our 580. There were some percentage accuracy issue noticed in the past but nothing like this. Having said that, I would like to confirm a couple of things related to the implementation.,
1. Is this pin P03 being used for any other purpose. The primary would be the CS Pin for Flash memory. This might cause some disturbance on the pin as it is loaded.
2. Can you test this on a different Dev Kit. This is to rule out any hardware related issue.
3. Can you test with the ADC with 3x attenuation modedisabledand check if there results are improved.

It is not clear what is causing this exactly but, I will keep you posted as I explore into this issue.

Best,
LC_Dialog

DavidW
Offline
Last seen:2 years 4 months ago
Joined:2017-11-17 08:35
Hi LC-Dialog,

Hi LC-Dialog,

1. I tought the same thing, but i checked all GPIO reservations and configuration for other purpose. I can't find anything.
2. If there is no solution i will by another 14580 chip and test this first.

3. Without 3x attenuation on channel P03 i get the highest value(1111111111), with 3x attenuation i get about 3,2V (1110001100 , 1110001101, 1110001011) . It doesn't matter what signal i create.
I also checked the pin with my oscilloscope and also the connection to the chip. No offset. Not the value getting as output.

Is there a possibility that you can get this 3,2V with software or any GPIO configuration?
Otherwise i think the chip has an internal damage.

Thanks
David

LC_Dialog
Offline
Last seen:3 weeks 4 days ago
Staff
Joined:2016-09-19 23:20
Hi David,

Hi David,

I am curious if you had a chance to try out the ADC implementation on a different kit?

Also, as it comes to be sometimes, the ADC might be disturbed if there is any activity going on over the other channels even though they are not being used for ADC purpose. Say if there is any UART activity etc., on channels 0/1/2 when the channel 3 is being used for ADC there might be some inconsistencies in the ADC readings. Please make sure that the timing is handled properly to avoid this scenario.

Coming back to the original question, there is still no explanation as to why you are getting only certain fixed incorrect values on the Channel 3 alone.

Regariding your question: Is there a possibility that you can get this 3,2V with software or any GPIO configuration?
If you are asking about mapping the ADC channel 3 to any other GPIO, I am afraid that is not possible as the 4 channels of the ADC are connected in hardware to the lower 4 pins of the Port 0.

Best,
LC_Dialog

DavidW
Offline
Last seen:2 years 4 months ago
Joined:2017-11-17 08:35
Hi LC_Dialog,

Hi LC_Dialog,

i will change the chip on my board in a few days.
I checked everything of software settings and i also tested a few hardware settings.
I found out that the value of the channel is VDD3V3. I takes a longer time because i always use the debugger with usb.
Aftert the usage of the battery or a voltage generator, the value is like the supply voltage.
I let you know if the problem is solved after changing the chip.

Regards,

David

DavidW
Offline
Last seen:2 years 4 months ago
Joined:2017-11-17 08:35
Hi LC_Dialog,

Hi LC_Dialog,

after changing the Da14580-chip the Channel P03 works. So it was a hardware problem.
Now all four channels work perfect. I don't know the reason of this damage but it's annoying that it takes so long.

Do you know the reference voltage and accuracy of the adc?
I did a few measurements and if i want to convert the value of the adc i calculate with 3.6V. But if i calculate with 3.7V as reference voltage, the converted value is more accurate to the voltage on the adc pins. I think the implemented software is correct.

Regards,
David

LC_Dialog
Offline
Last seen:3 weeks 4 days ago
Staff
Joined:2016-09-19 23:20
Hi David,

Hi David,

That is good to know the issue is resolved. Though the hardware damages are pretty rare and can happen due to many reasons like storing outside longer after opening the package, ESDs in production etc.,

Regarding the accuracay, there is a very good reference in the DA14580 Known Issues document for the ADC measurements and precautions. Please review the document and reach us back regarding any clarifications.

Best,
LC_Dialog