I am programming the cc2540 in IAR with the latest BLE stack from TI.
I am trying to read the battery voltage using one of the analog pins and an internal reference. I am interested in the raw adc value. My attempt is summarized below and is based roughly on the example from http://e2e.ti.com/support/wireless_connectivity/f/538/t/72681.aspx?pi310978=3
1. Add 'HalAdcInit();' to the initialization function
2. Configure analog port for input
APCFG = 0x80; // Set HAL_ADC_CHANNEL_7 to input
3. Set internal reference and read analog value during periodic function
HalAdcSetReference( HAL_ADC_REF_125V );
uint8 adc = HalAdcRead ( HAL_ADC_CHANNEL_7, HAL_ADC_RESOLUTION_10);
Using these four lines I get a value of approximately 0x50 for adc. When the battery is read on a multimeter it reads 2.86V. Furthermore, these readings do not align with the battservice.c description.
What do I need to modify to get better results or are my results just a different correct answer?