I used the example pin_change_int from peripheral examples and commented the OUT pins. In addition I added the sleep commands to the main while loop. This is the code:
#define PIN_IN BSP_BUTTON_0
#error "Please indicate input pin"
#define PIN_OUT BSP_LED_0
#error "Please indicate output pin"
void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
* @brief Function for configuring: PIN_IN pin for input, PIN_OUT pin for output,
* and configures GPIOTE to give an interrupt on pin change.
static void gpio_init(void)
err_code = nrf_drv_gpiote_init();
//nrf_drv_gpiote_out_config_t out_config = GPIOTE_CONFIG_OUT_SIMPLE(false);
//err_code = nrf_drv_gpiote_out_init(PIN_OUT, &out_config);
nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_TOGGLE(true);
in_config.pull = NRF_GPIO_PIN_PULLUP;
err_code = nrf_drv_gpiote_in_init(PIN_IN, &in_config, in_pin_handler);
* @brief Function for application main entry.
When I power profile it right after turning the device on, I get a nice expected current consumption of 32uA as seen below
However, as soon as I press the button per code, the consumption goes high and stays high. I was expecting it to spike up but then go back to normal. Why is this occurring? I am using the DK board and using the regular board button 0 for this. Why is it using so much current consistently?
could it be that
in_config.pull = NRF_GPIO_PIN_PULLUP;on the code is not working? therefore the pin is floating?
I dug a bit further and found ran the debugger. Found out that the in_pin_handler is being called twice on every key press. I wonder if this is causing high consumption. Why would the code above call in_pin_handler twice on the same button press?
Could you tell me which DK you are working with, so that I can test this myself?
Also; are you seeing the high current consumption on a single button press (press and release) or are you holding the button down?
Best regards, Joakim Jakobsen
Single fast button press and release. DK: PCA10056 1.1.0 2019.19 683309915 nrf52840
btw, I tested 2 different DKs with the same results. At one rare point, it actually temporarily spiked up the current when I pressed the button and went back to the original state. But that only happened like twice. The rest of the time, no matter how many times I restarted the DK it would spike up on the first button press. And then stays at 200+uA from there