Using ADC to read port 0 pin 0 voltage

7 posts / 0 new
Last post
motred
Offline
Last seen:5 years 4 months ago
Expert
加入:2014-01-20 21:48
Using ADC to read port 0 pin 0 voltage

Hi,

I'm trying to use the ADC to read port 0 pin 0, and I'm always getting a value of 0 from adc_get_sample().

I have port 0 pin 0 reserved as follows:
RESERVE_GPIO(BATT_MEAS, GPIO_BAT_MEAS_PORT, GPIO_BAT_MEAS_PIN, PID_ADC);
GPIO_ConfigurePin(GPIO_BAT_MEAS_PORT, GPIO_BAT_MEAS_PIN, INPUT, PID_ADC, false);

Then I try to read the ADC like this:
adc_init(GP_ADC_SE, GP_ADC_SIGN);
adc_enable_channel(ADC_CHANNEL_P00); // NOTE: Change in channel used - ADC_CHANNEL_VBAT3V);
uint16_t adc_sample = adc_get_sample();
adc_disable();

When I do this, I always get adc_sample == 0.

Am I doing something wrong here? I didn't see any other advice in the peripheral drivers document.

R.Gantner
Offline
Last seen:1 week 1 hour ago
加入:2014-01-18 13:57
Hi,

Hi,
Try to increase the voltage on P0.0 . If the voltage is below 0.2V (? this is a assumption ?) you will get always 0.

RvA
Offline
Last seen:1 day 20 hours ago
Staff
加入:2014-02-07 14:10
Hi, I have a working example

Hi, I have a working example below on using the ADC:

uint16_t adc_read_P01_channel ()
{
uint16_t adc_sample;

// ADC INIT
adc_init(GP_ADC_SE, 0); // Single ended mode

adc_enable_channel(ADC_CHANNEL_P01); // ADC_CHANNEL_P01
adc_sample = adc_get_sample(); // start conversion
return (adc_sample);
}

The main difference is the explicit declaration of the variable in the first line : uint16_t adc_sample;

Could you give this a try in your example?
Best regards,
RvA (Dialog)

motred
Offline
Last seen:5 years 4 months ago
Expert
加入:2014-01-20 21:48
I got it working on my devkit

I got it working on my devkit with your code, RvA. It looks like the problem with my hardware may be with hardware :P

Thanks for the help.

hrg
Offline
Last seen:2 years 3 months ago
Guru
加入:2014-08-05 13:37
For P0.0 with your code its

For P0.0 with your code its always showing 00 !! And why each port pins P0.0 ,0.1,0.2,0.3 , are in different voltages ???

motred
Offline
Last seen:5 years 4 months ago
Expert
加入:2014-01-20 21:48
hrg, I'm also still having

hrg, I'm also still having issues with this.
It looks like it might be a hardware error, because the ADC works with a voltage applied directly to the pin but not with a resistive divider. Have you tried using a DC power supply to test your ADC? If that works, then your issue is probably with the resistive divider.

I've created a new question for the resistive divider problem here:http://support.dialog-semiconductor.com/using-adc-read-voltage-divider-v...

jeremy_xu
Offline
Last seen:5 years 5 months ago
加入:2015-07-23 07:47
Hi ! Dialog team, I have two

Hi ! Dialog team, I have two questions:
1. How can I get the accurate voltage that is same with the measured voltage, whatever how I set the register , I cannot get the accurate voltage?
2. whether the hardware error cannot be eliminated, which caused by DA14580 ?