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

Current consumption when using rtc, ppi and gpiote

Hi Sir/Madam

I wrote a small program for low current verification on nrf51822 development kit with starter mother board. The program is based on "blinky_example" project configuration. It is doing gpio pin 24 toggling by using rtc, ppi and gpiote modules. However, the voltage reading from connector K2 is about 120mV or 1200uA at P7 even the CPU is called "__WFI" and unplugged the Jlink. From my understanding, CPU can operate below 5uA when it is sleep. Or ppi module is already used 1mA? Or something wrong on the code. Thanks a lot.



#define LFCLK_FREQUENCY          (32768UL)             /*!< LFCLK frequency in Hertz, constant */
#define RTC_FREQUENCY             (8UL)                     /*!< required RTC working clock RTC_FREQUENCY Hertz. Changable */
#define COMPARE_COUNTERTIME       (1UL)            /*!< Get Compare event COMPARE_TIME seconds after the counter starts from 0 */

#define COUNTER_PRESCALER         ((LFCLK_FREQUENCY/RTC_FREQUENCY) - 1)  /* f = LFCLK/(prescaler + 1) */


void ppi_init(void)
{
	// Configure PPI channel 0 to start ADC task	
	NRF_PPI->CH[0].EEP = (uint32_t)&NRF_RTC0->EVENTS_TICK;	
	NRF_PPI->CH[0].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[0];

	// Enable PPI channel 0
	NRF_PPI->CHEN = (PPI_CHEN_CH0_Enabled << PPI_CHEN_CH0_Pos);
}

static void rtc_config(void)
{
	NRF_RTC0->PRESCALER = COUNTER_PRESCALER;                   // Set prescaler to a TICK of RTC_FREQUENCY
	
	// Enable TICK event and TICK interrupt:
	NRF_RTC0->EVTENSET = RTC_EVTENSET_TICK_Msk;
}

static void lfclk_config(void)
{
	NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos);
	NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
	NRF_CLOCK->TASKS_LFCLKSTART = 1;
	while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0)
	{
	}
	NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
}

/**
 * main() function
 * @return 0. int return type required by ANSI/ISO standard.
 */
int main(void)
{
	nrf_gpio_cfg_output(24);
	lfclk_config();
	rtc_config();

	ppi_init();
       
        // Configure the GPIOTE Task to toggle the LED state.
    nrf_gpiote_task_config(0,                         
						   24,
                           NRF_GPIOTE_POLARITY_TOGGLE,						   
                           NRF_GPIOTE_INITIAL_VALUE_LOW);

	
	NRF_RTC0->TASKS_START = 1;
	
    // Enter main loop
    for ( ; ; )
    {		
		__WFI();
	}	
}

Parents
  • Hi

    The GPIOTE IN events and OUT tasks have had current consumption issues both for our first revision hardware and the current second revision hardware. We have recommended not to use it for low current applications. The reason was that the high frequency 16MHz clock is always enabled while the GPIOTE IN events or OUT tasks are enabled, consuming about ~1mA of current.

    Until now, use of the GPIOTE IN events have been avoided by using the GPIOTE PORT event instead, which is very low current (<1uA). The port event however does have a drawback because it does not know from which pin the interrupt was generated. However, the app_button library uses the PORT event and compensates for its drawback. The GPIOTE OUT tasks have however not been usable until now for low current applications.

    The third revision hardware of the nRF51 has a solution for the GPIOTE OUT tasks, which has very low current consumption (<1uA). The third revision nRF51 hardware will be released in a few days. The third revision hardware still does not have a solution for the GPIOTE IN events, they still consume high current, so for low current applications, use the GPIOTE PORT event instead or the app_button libary.

  • Hi Stefan, is there an official document describing the high current consumption when using GPIOTE IN? I'm writing a Bachelor Thesis and my project is based on the NRF51822, so I need a reference when describing the current consumption.

Reply Children
No Data
Related