How to measure the VDD_PADS voltage on the EM35x series chips?
Answer
The data sheet states "The regulator input voltage, VDD_PADS, cannot be measured using the general purpose ADC, but it can be measured through Ember software." The reason is because VDD_PADS is not one of the selectable analog inputs for the user-exposed ADC, but it is available on the internal CALADC. Hence we provide an API, halMeasureVdd() in the HAL library that does this (per hal/micro/cortexm3/adc.h):
/** @brief Measures VDD_PADS in millivolts at the specified sample rate
* Due to the conversions performed, this function takes slightly under 250us
* with a variation across successive conversions approximately +/-20mv of
* the average conversion.
*
* @return A measurement of VDD_PADS in millivolts.
*/ uint16_t halMeasureVdd(ADCRateType rate);
If VDD_PADS is being driven by a DC-to-DC converter, then the customer would probably want to route the battery voltage input to that also to an analog GPIO of their choice, perhaps voltage divided to meet analog input criteria, and measure that using the normal ADC. There is an API to assist converting the ADC's reading to volts (per hal/micro/adc.h):
/** @brief Convert the raw register value (the unaltered value taken
* directly from the ADC's data register) into a signed fixed point value with
* units 10^-4 Volts. The returned value will be in the range -12000 to
* +12000 (-1.2000 volts to +1.2000 volts).
*
* @appusage Use this function to get a human useful value.
*
* @param value An uint16_t to be converted.
*
* @return Volts as signed fixed point with units 10^-4 Volts.
EM35x - Using Software to Measure VDD_PADS