This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

adc wrong values

Hi I have nrf51822 CEAA which is powered with 1.9 volt on vdd (low power chip). I'm using ADC to measure battery level but the conversion gave me 5.4 volt wich is wrong for the battery

here my adc configuration

NRF_ADC->INTENSET = (ADC_INTENSET_END_Disabled << ADC_INTENSET_END_Pos);		/*!< Interrupt disabled. */                                                                                // config ADC
	switch (channel) {
	case CH_BATT:                                                                                                                          /* Battery voltage */
		NRF_ADC->CONFIG = (ADC_CONFIG_EXTREFSEL_None << ADC_CONFIG_EXTREFSEL_Pos)   /* Bits 17..16 : ADC external reference pin selection (no ref). */
			| (AIN_BAT << ADC_CONFIG_PSEL_Pos)                                          /*!< Use analog input "AIN_BAT" as analog input. */
			| (ADC_CONFIG_REFSEL_VBG << ADC_CONFIG_REFSEL_Pos)                      /*!< Use internal 1.2V bandgap voltage as reference for conversion. */
			| (ADC_CONFIG_INPSEL_AnalogInputOneThirdPrescaling << ADC_CONFIG_INPSEL_Pos) /*!< Analog input specified by PSEL with 1/3 prescaling used as input for the conversion. */
			| (ADC_CONFIG_RES_10bit << ADC_CONFIG_RES_Pos);                         /*!< 10bit ADC resolution. */ 

I joined here the schematic. the input is IMG_BAT P0.01

the second answer of this question

VDD 1.8, prescaling 1/3: AIN max 2.1V (rule 2 limitation). is that mean that the input should not exceed 2.1 volt (battery can go to 4.2 volt)

should I put resistors to reduce battery voltage, so that the max input be 2.1 (at 4.2 battery voltage, ADC input is 2.1)???

  • The maximum rating on a gpio pin is VDD+0.3V, see product specification absolute maximum ratings. This means that the maximum voltage in your case is 2.2V (1.9V+0.3V), so you will need a voltage divider from the battery to the gpio pin. I would configure the voltage divider such that the maximum voltage on the pin is 1.2V (VBG) and then used AnalogInputNoPrescaling and refsel VBG to utilize the full range of the ADC.

    I don't know why you are measuring 5.4V, but since you are outside the operating conditions for the chip it doesn't matter.

Related