This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Attaching Interrupt increases power to 200uA

I have a very simple test script which enables a BLE service (only the Generic Access and Attribute), advertises and waits for connection. It also sets four pins to input pins. I am using the Arduino environment and a MDBT40 raytac module.

During that process I get rougly 10uA power consumption.

Upon connection (within the connection callback) i attach an interrupt to one of those pins. When I do this the current consumption rises to 200 (ish) uA. When the interrupt fires the current consumption goes back to ~10uA.

I use the following commands before going into waitForEvent mode:

 NRF_POWER->DCDCEN = 0x00000001;
  NRF_TIMER1->POWER = 0;
  NRF_TIMER2->POWER = 0;     
  NRF_UART0->POWER  = 0;
  NRF_ADC->ENABLE  = (ADC_ENABLE_ENABLE_Disabled << ADC_ENABLE_ENABLE_Pos);
  NRF_ADC->POWER   = 0;   
  NRF_TWI0->POWER   = 0;  
  NRF_TWI1->POWER   = 0; 
//  NRF_GPIOTE->INTENSET = 0;
//  NRF_GPIOTE->POWER = 0;

  NRF_SPI0->ENABLE = 0;
  NRF_SPI0->POWER = 0;

I really dont understand why attaching an interrupt is causing the power consumption to rise, I then understand even less why when the itnerrupt fires the power consumption drops breifly back to where it is expected to be. Am I missing something obvious?

Edit 1 I'm using the following code to attach and detach the interrupt. It doesn't change the power if i detach the interrupt and if I never attach the itnerrupt but connect over bluetooth then the power usage does not increase to 200uA

    void attachInterrupt(uint32_t pin, irqHandle_t handle, uint8_t mode)
{
    PinName nrf_pin;

    nrf_pin = Pin_nRF51822_to_Arduino(pin);

    if(nrf_pin == (PinName)NC || handle == NULL )
        return;

    if(mode != CHANGE && mode != FALLING && mode != RISING )
        return;

    if(mode == CHANGE) {
        pinHandle[(uint32_t)nrf_pin].riseHandle = handle;
        pinHandle[(uint32_t)nrf_pin].fallHandle = handle;
    }
    else if(mode == RISING) {
        pinHandle[(uint32_t)nrf_pin].riseHandle = handle;
        pinHandle[(uint32_t)nrf_pin].fallHandle = NULL;
    }
    else {
        pinHandle[(uint32_t)nrf_pin].riseHandle = NULL;
        pinHandle[(uint32_t)nrf_pin].fallHandle = handle;
    }

    gpio_irq_init(&pinHandle[(uint32_t)nrf_pin].gpio_irq, nrf_pin, gpio_irq_handle_cb, (uint32_t)&pinHandle[(uint32_t)nrf_pin]);
    gpio_init_in(&pinHandle[(uint32_t)nrf_pin].gpio, nrf_pin);

    if(mode == CHANGE) {
        gpio_irq_set(&pinHandle[(uint32_t)nrf_pin].gpio_irq, IRQ_RISE, 1);
        gpio_irq_set(&pinHandle[(uint32_t)nrf_pin].gpio_irq, IRQ_FALL, 1);
    }
    else if(mode == RISING) {
        gpio_irq_set(&pinHandle[(uint32_t)nrf_pin].gpio_irq, IRQ_RISE, 1);
    }
    else {
        gpio_irq_set(&pinHandle[(uint32_t)nrf_pin].gpio_irq, IRQ_FALL, 1);
    }
}


void detachInterrupt(uint32_t pin )
{
    PinName nrf_pin;

    nrf_pin = Pin_nRF51822_to_Arduino(pin);

    gpio_irq_free(&pinHandle[(uint32_t)nrf_pin].gpio_irq);
    memset(&pinHandle[(uint32_t)nrf_pin], 0x00, sizeof(PinHandle_t));
    pinHandle[(uint32_t)nrf_pin].riseHandle = NULL;
    pinHandle[(uint32_t)nrf_pin].fallHandle = NULL;
}
  • Hi, Is it possible that you have an internal pull up/down resistor that draws current? The internal pull resistors have a typical value of 13 kOhm. If you e.g. have Vdd=~3V and a GPIO pin configured as an input with pullup enabled and then the pin is pulled to GDN the resistor will draw 3/13k = ~230uA.

  • Hi Martin, Turns out this was the case! although I was not giving them pullup pins, the internal RedBear libraries I was using wrap up some mbed code which by default pulled the pin high. After a day or so of chasing this seemed to be the issue

Related