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.
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.
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)
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.
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 ???
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...
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 ?