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

Why Battery level is always 100?

static void adc_init(void)

{

/* Enable interrupt on ADC sample ready event*/		

NRF_ADC->INTENSET = ADC_INTENSET_END_Msk;   

sd_nvic_SetPriority(ADC_IRQn, NRF_APP_PRIORITY_LOW);  

sd_nvic_EnableIRQ(ADC_IRQn);

NRF_ADC->CONFIG	= (ADC_CONFIG_EXTREFSEL_None << ADC_CONFIG_EXTREFSEL_Pos) 
		| (ADC_CONFIG_PSEL_Disabled << ADC_CONFIG_PSEL_Pos)					
		| (ADC_CONFIG_REFSEL_SupplyOneThirdPrescaling << ADC_CONFIG_REFSEL_Pos)							
		| (ADC_CONFIG_INPSEL_SupplyOneThirdPrescaling << ADC_CONFIG_INPSEL_Pos) 
		| (ADC_CONFIG_RES_8bit << ADC_CONFIG_RES_Pos);									

/* Enable ADC*/
NRF_ADC->ENABLE = ADC_ENABLE_ENABLE_Enabled;

}

void ADC_IRQHandler(void)

{

uint8_t adc_result;
	
    NRF_ADC->EVENTS_END = 0;	

ADC_Value = (NRF_ADC->RESULT)/255*100;

    NRF_ADC->TASKS_STOP = 1;

sd_clock_hfclk_release();

}

The result of this source is always 100.

The amount of the battery is falling but 100.

What is the problem?

I have connected the battery to the VTG and GND.

What part did wrong?

Parents
  • You wrote in a comment to Mango922:

    but I need a voltage higher than 4.5V

    If I need a voltage higher than 4.5V, Will always get 100 results?

    Result of My source is always 1023. (ADC 10bit)

    Please read section 31.1.1 Set input voltage range in the nRF51 Series Reference manual. Here it is written:

    There are two rules to follow to find the maximum input voltage allowed on the AIN pins:

    1. The ADC should not be exposed to higher voltage than 2.4 V on an AIN pin after prescaling: Input voltage x prescaling = max. 2.4 V. 31 Analog to Digital Converter (ADC) Page 166
    2. A GPIO pin must not be exposed to higher voltage than VDD + 0.3 V, according to the Absolute maximum ratings from the nRF51x22 Product Specification.

    Also please read section 31.1.2 Using a voltage divider to lower voltage.

Reply
  • You wrote in a comment to Mango922:

    but I need a voltage higher than 4.5V

    If I need a voltage higher than 4.5V, Will always get 100 results?

    Result of My source is always 1023. (ADC 10bit)

    Please read section 31.1.1 Set input voltage range in the nRF51 Series Reference manual. Here it is written:

    There are two rules to follow to find the maximum input voltage allowed on the AIN pins:

    1. The ADC should not be exposed to higher voltage than 2.4 V on an AIN pin after prescaling: Input voltage x prescaling = max. 2.4 V. 31 Analog to Digital Converter (ADC) Page 166
    2. A GPIO pin must not be exposed to higher voltage than VDD + 0.3 V, according to the Absolute maximum ratings from the nRF51x22 Product Specification.

    Also please read section 31.1.2 Using a voltage divider to lower voltage.

Children
No Data
Related