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

nrf51: energy saving compliance with ADC_IRQn and power_manage

Hi

I am trying to broacast advdata (1 second advertisement period) including battery level (0..100) and a counter

My doubt is related with ADC_IRQn fired period and power_manage waikeup. Here is the main function:

int main(void)
{
   leds_init();

   ble_stack_init(); //Advertisement of 1s
   

   start_timer(); //NRF_TIMER2 for 1s. Blinks LED, increment count and writes counter and battery to advdata and calls sd_ble_gap_adv_data_set

   battery_start(); //then in ADC_IRQHandler I save value in global var to be used by NRF_TIMER2 handler 

   advertising_init();

   advertising_start();

   while(1)
   {
      power_manage(); 
   }
}

Well, I know that interrupt handlers must be as short ad possible (without heavy operations). So NRF_TIMER2 shuld just inc counter and nothing more. Then, after power_manage(), adbdata must be updated and sd_ble_gap_adv_data_set should be called. But apart from this, what happens to power_manage call? Is it waked up by ADC_IRQn event?

Imagine that I would like to broadcast advdata with 10 seconds period (max). If I use ADC_IRQn that means that power_manage is beeing constantly waked up by ADC_IRQn interrupt?

Is it possible to configure ADC_IRQn to fire with 10 seconds period also in order to be "compliant" with power_manage.

By default, what is the fire period for ADC_IRQn?

Should I use polling for battery reading instead and call it from 5 to five minutes, for instance? (because battery does not drops too quickly)

Thanks a lot

Alex

  • Hi, For low power operation you should use app_timer to periodically start operations, such as reading an external sensor or start an adc operation. I recommend to use app_timer, because NRF_TIMER will use higher current consumption. After starting the tasks there may be additional interrupts, such as ADC_IRQn, where the application can process the data. In between the app_timer and hardware interrupts the power_manage() will sleep the CPU and system, and only wakeup when there is an event that needs to be handled. 

  • Even though, if ADC_IRQn fires multiple times per second (I cant guess the periodicity of this timer. Can you tell me please?) it will be waking up the power_manage/ processor. So it seems for me that sensor reading and ADC_IRQn must be aligned with BLE advertisements period in order to avoid unnecessary wake ups. Is that true?

    Wouldnt be advantageous to use (battery reading) ADC is pooling mode instead of interrupt mode. Using polling mode would be a way to avoid unnecessary wake ups? We just call battery reading/conversion when we need it...?!

  • The execution time is the same, so I don't see any major benefit of waking up one time for longer period vs. several times for shorter period. Using app_timer to wakeup at configurable intervals I believe is the common way.

Related