Hello CircuitDojo Community,

I have been working on an nRF9160, Nordic ncs 1.6.1 and Zephyr based project. Past six weeks have been focused on reaching deep sleep modes and floor currents in single micro-ampere range both in development board and custom board. I’ve been testing configs where I set every GPIO to Zephyr’s GPIO_DISCONNECTED state, as part of this effort. Recently discovered I’d missed one pin, an input that’s connected to the board’s “user purposed” push button.

When I add the following Zephyr API call:

gpio_pin_configure(dev_s1, SW0_PIN, GPIO_DISCONNECTED);

…I find that the push button still triggers firmware that’s checking for push button press events, code which reads whether the state of that pin is found to be high or low.

I went further and modified my board’s DTS file, [custom_board]_common.dts:

        buttons {
                compatible = "gpio-keys";

                button0: button_0 {
                        gpios = <&gpio0 22 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
                        label = "Button 1"; 
                        status = "disabled";
                };  
        };  

…so that the device is disabled at compile time. Yet the button remains active, and firmware responds to button presses.

What basic detail am I failing to see here? Feels like I may be making a dumb mistake. I’d like to be able to control this GPIO, so that in case the original configuration I chose or inherited is drawing some current I could otherwise save, I may turn that off, for battery life purposes.

Thanks ahead of time for any help community here can offer!

  • Ted

    Are you registering for an interrupt on that pin somewhere earlier in your application?

      tedhavelka66 GPIOs don’t get initialized by the overlay, you do that in your code. You’ll have to go where you initialize it and investigate further.

      Additionally, the big gotcha for Zephyr is that if you’re using MCUBoot and SPM. They both do their own thing and initialize peripherals before your application starts. So if one initializes Uart1 (for instance) but you don’t use Uart1 in your application, you may well be paying the price in your current draw.

      Hope that helps 😄

        Hello ThomasFike and jaredwolff ,

        Thank you both for the helpful replies! It turns out there is code I overlooked which configures the pin attached to push button with an interrupt enabled on it. Removing that configuration drops current consumption by about 20 microamps. Help much appreciated!

        And Jared you helped a couple months back in post 222 when you shared your nfed v1.7.1 code base, and the active_sleep project. I noticed and asked about the project directory named ‘child_image’ in which there is a lone Kconfig file. That file specifically disables serial in the SPM project. Seems to work something like the device tree overlay files, except in this case for Kconfigurations.

        I am now employing child_image project directory with appropriate Kconfig changes to SPM and third party code bases in present project.

        Thank you again both. This kind of help (getting fellow developer unstuck) really makes a difference during the longer slogs. Stay safe both!

        • Ted
        Terms and Conditions | Privacy Policy