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

Accurate ADC measurement without the Soft Device

I'd like to measure the voltage of a lithium ion battery every minute or so in a way that's highly accurate. I need to do this without using the Soft Device because a) I need all the memory I can get for logging the voltages and b) what I'm really testing is a generator that's charging my battery so I want the power consumption of my board while I'm testing to be fairly low.

There's plenty of discussion about using the high frequency clock with the soft device to get an accurate ADC reading here:

devzone.nordicsemi.com/.../adc-softdevice-sample-rate-on-nrf51822

That code does this ten times a second:

static void adc_sampling_timeout_handler(void * p_context)
{
	uint32_t p_is_running = 0;
		
	sd_clock_hfclk_request();
	while(! p_is_running) {  							//wait for the hfclk to be available
		sd_clock_hfclk_is_running((&p_is_running));
	}               
	nrf_gpio_pin_toggle(NRF6310_LED_2);		//Toggle LED2 to indicate start of sampling
	NRF_ADC->TASKS_START = 1;							//Start ADC sampling
}

and then releases the clock at the end of the IRQ handler:

sd_clock_hfclk_release();

My question is, how do I do the same thing but without use of the Soft Device?

Parents Reply Children
No Data
Related