I'm having a hard time getting my ADC to work. I've followed the example and datasheets to get a sample from P0_2, but can't seem to get a full 0-1023 range that I should with a 10 bit ADC. From the datasheet, I should be maxing out at 1.2V, but I only get a value around 320 when I test it in the debugger with the pin connected to a power supply.
This is the code I use:
adc_init(GP_ADC_SE,0);
adc_enable_channel(ADC_CHANNEL_P02);
sample = adc_get_sample();
adc_disable();
I've reserved the pin as follows:
RESERVE_GPIO( ADC, GPIO_PORT_0, GPIO_PIN_2, PID_ADC );
Please let me know if anyone has successfully gotten an ADC pin to read the whole range.
Turns out the 3x attenuator was set as the default... Referred tohttp://support.dialog-semiconductor.com/using-adc-read-voltage-divider-v...
Thankyou Atching... we are working on an apps note for the ADC , since the documentation in the datasheet is not that great right now with regard to configuration.. the attentuator has caught out a few people. Glad you got that working.
BR JE_Dialog