power consumption problem

Muntaek Kim gravatar image

asked 2017-04-21 08:40:16 +0100

sigurdon gravatar image

updated 2017-04-21 11:17:09 +0100

Hi,

I'm using nrf51822 / sd130 / sdk 12.1. I am doing minimizing current consumption. My main function is like below. I checked no wakeup in sleep mode. But, current consumption changes variously. It is wide from ~30uA to 1.5mA. What should I do additionally? I'm trying various condition.

thanks.


while (1)
{
        // fucntion execute


    NRF_CLOCK->TASKS_HFCLKSTART = 0;       // for test
    NRF_CLOCK->TASKS_HFCLKSTOP = 1;        // for test

    NRF_POWER->TASKS_LOWPWR = 1;           // for test
//  NRF_POWER->SYSTEMOFF = 1;              // for test

    // Make sure any pending events are cleared
    __SEV();
    __WFE();
    // Enter System ON sleep mode
    __WFE();

         // watchdog
    nrf_drv_wdt_channel_feed(m_channel_id); // wdt feed

    NRF_CLOCK->TASKS_HFCLKSTOP = 0;        // for test
    NRF_CLOCK->TASKS_HFCLKSTART = 1;       // for test
   }

watchdog setting

// <1=> Run in SLEEP, Pause in HALT 
// <8=> Pause in SLEEP, Run in HALT 
// <9=> Run in SLEEP and HALT 
// <0=> Pause in SLEEP and HALT 

    #ifndef WDT_CONFIG_BEHAVIOUR
    #define WDT_CONFIG_BEHAVIOUR 8                  // 8, mtkim modified, 1 : original
    #endif
edit retag flag offensive close delete report spam

Comments

What else are you doing in main() function? I tested the code you have in the while-loop with the wdt example in the SDK, and measured average 3 µA power consumption.

Sigurd ( 2017-04-21 14:11:43 +0100 )editconvert to answer

My confiturations are like below - 1 twi, 2 pwm, 12 lower power event input pins, 1 adc - others : normal GPIO in/output

I am doing some actions before sleep. - 1 twi, 2 pwm, 1 adc -> disable using library function - 12 lower power event input pins -> active for wakeup - others : normal GPIO in/output -> no action

Is there any documents related with power consumption?

Thanks.

air ( 2017-04-24 06:12:13 +0100 )editconvert to answer

We have a current consumption guide for the nRF51 here you can take a look at. You are completely turning off the TWI, PWM and ADC before going to sleep ? Are you using BLE ? How long are you sleeping before you wake-up again?

Sigurd ( 2017-04-24 11:25:50 +0100 )editconvert to answer

I added below code right before sleep. I saw lower current consumption than before. Is below code necessary? I'll read more document you mentioned.

Thanks.

        NRF_TWI0->ENABLE = 0;
        NRF_TWI0->POWER = 0;

// NRF_RADIO->ENABLE = 0; /!< Peripheral power control. */ NRF_RADIO->POWER = 0; /!< Peripheral power control. / NRF_UART0->ENABLE = 0; /!< Peripheral power control. / NRF_UART0->POWER = 0; /!< Peripheral power control. / NRF_SPI0->ENABLE = 0; /!< Peripheral power control. / NRF_SPI0->POWER = 0; /!< Peripheral power control. / NRF_SPIS1->ENABLE = 0; /!< Peripheral power control. / NRF_SPIS1->POWER = 0; /!< Peripheral power control. / // NRF_GPIOTE->ENABLE = 0; /!< Peripheral power control. / NRF_GPIOTE->POWER = 0; /!< Peripheral power control. / NRF_ADC->ENABLE = 0; /!< Peripheral power control. / NRF_ADC->POWER = 0; /!< Peripheral power control. / // NRF_TIMER0->ENABLE = 0; /!< Peripheral power control. / NRF_TIMER0->POWER = 0; /!< Peripheral power control. / // NRF_TIMER1->ENABLE = 0; /!< Peripheral power control. / NRF_TIMER1->POWER = 0; /!< Peripheral power control. / // NRF_TIMER2->ENABLE = 0; /!< Peripheral power control. / NRF_TIMER2->POWER = 0; /!< Peripheral power control. / // NRF_RTC0->ENABLE = 0; /!< Peripheral power control. / NRF_RTC0->POWER = 0; /!< Peripheral ...(more)

air ( 2017-04-24 12:04:44 +0100 )editconvert to answer

I assume that you are using the drivers. So you should use the relevant driver functions to uninitialize and disable the peripherals you want to disable. E.g. first nrf_drv_twi_uninit() and thennrf_drv_twi_disable() to disable the TWI.

Sigurd ( 2017-04-24 16:48:16 +0100 )editconvert to answer

I'll recheck to turn off all peripherals. Thanks for your reply.

air ( 2017-04-25 02:47:35 +0100 )editconvert to answer

* 1st question * I use timer1/2 for 2 - PWM. I turn on(POWER = 1) each timer before PWM start(init()) and turn off(POWER = 0) each timer after PWM stop(uninit()). I get current save by doing this. But, Reset occurs after several above PWM action - mainly when PWM1 is called. I use makeSound() to change beep sound level. It’s called by different sound level. I don’t know there is anything wrong. Sure, reset never occurs without using turn on/off.


ENABLE_TIMER1;

void makeSound(uint16_t level) // PWM1 { ret_code_t err_code;

app_pwm_uninit(&PWM_BUZZER);
app_pwm_config_t pwm1_cfg = APP_PWM_DEFAULT_CONFIG_1CH(level, BUZZER_PIN);
pwm1_cfg.pin_polarity[0] = APP_PWM_POLARITY_ACTIVE_HIGH;

err_code = app_pwm_init(&PWM_BUZZER, &pwm1_cfg, NULL);
APP_ERROR_CHECK(err_code);
app_pwm_enable(&PWM_BUZZER);

}


* 2nd question * I set CLOCK_CONFIG_LF_SRC 0 (RC). This makes current consumption be lower than XTAL setting. Is XTAL setting essential in BLE function environment? Is calibration essential for the exact timing (RTC)? I don’t want calibration for lower current consumption.

air ( 2017-04-26 07:01:47 +0100 )editconvert to answer

1) "But, Reset occurs after several above PWM action " Does the nRF51 reset? This is a sign of of an error passed to the APP_ERROR_CHECK() macro. See this post about debugging.

2) To run BLE on NRF51 you will need an external 16 MHz crystal for the HFCLK(HFXO). As LFCLK you can then either use external 32 kHz crystal(LFXO) or interal RC oscillator(LFRC). The LFRC will have a slighlty higher current than the LFXO.

The TIMER peripheral uses the HFCLK. Using the interal 64 MHz internal oscillator(HFINT) as HFCLK you will have less current consumption, but the accuracy of the HFINT is not good enough to run BLE. The HFXO will have higher current consumption, but it have much better accuracy(ppm) and is needed to run BLE.

Sigurd ( 2017-04-26 16:55:24 +0100 )editconvert to answer

I use below code for beep sound output. MCU is always in sleep status except these function execution. MCU wakes up by SW input and onSound() is 1st called after wakeup. When using makeSound() I can saw abnormal or reset nrf51. But without using makeSound() it works well. I don't know why. I'll check more.

Thanks.

// 1st call for beep sound from main void onSound(uint8_t Num) { // offSound();

timerBuzzer(STOP, NULL);

BUZZER_USE;
ENABLE_TIMER1;

if(Num != BEEP_DOOR_ALARM)
    doorAlarmBeepCnt = 0;                       // door open alarm beep cancel

beepOrder = 0;
beepCnt = beepCntInfo[Num];
soundNum = Num;

makeSound(beepLevel[soundNum][beepOrder]);
controlLed(ledInfo[soundNum][beepOrder]);
timerBuzzer(START, beepTime[soundNum][beepOrder]);

}

// for buzzer disable void disableBuzzer(void) { ret_code_t err_code;

app_pwm_disable(&PWM_BUZZER);

// err_code = app_pwm_end(&PWM_BUZZER); // APP_ERROR_CHECK(err_code); DISABLE_TIMER1;

nrf_gpio_pin_clear(BUZZER_PIN);
nrf_gpio_cfg_output(BUZZER_PIN);

BUZZER_NO_USE;

}

// for beep strength/tone, called by onSound() and buzzer timer handler void makeSound(uint16_t level) { ret_code_t err_code;

err_code = app_pwm_uninit(&PWM_BUZZER);

// APP_ERROR_CHECK(err_code); // app_pwm_disable(&PWM_BUZZER ...(more)

air ( 2017-04-27 10:06:35 +0100 )editconvert to answer

define DISABLE_TIMER1 {NRF_TIMER1->POWER = 0;}

define DISABLE_TIMER2 {NRF_TIMER2->POWER = 0;}

define ENABLE_TIMER1 {NRF_TIMER1->POWER = 1;}

define ENABLE_TIMER2 {NRF_TIMER2->POWER = 1;}

I know timer1 enters shutdown mode in app_pwm_disable(&PWM_BUZZER). But, without these definition it consumes current more.

air ( 2017-04-27 10:52:18 +0100 )editconvert to answer

How much more current consumption are you measuring? All peripherals are powered by default, and it should not draw any extra current leaving them powered on.

Sigurd ( 2017-04-28 11:23:22 +0100 )editconvert to answer

It consumes above 300uA. I don't know if this is because of timer entirely. Anyway I solved this problem. I found some delay is needed after timer power on. If without this delay pwm works abnormally. But, I wonder why more current is consumed after app_pwm_disable(). In code app_pwm_disable() makes timer shutdown.

Thanks.

air ( 2017-04-29 02:43:41 +0100 )editconvert to answer