P1.00 GPIO on 4x3 keypad not detecting Col

Good day

I have the NRF_desktop keyboard application running on the NRF52840 Dongle,  Zephyr 2.6.1. I would like to us the nrf52840 ProMicro as it has a battery charger build in. I have modified rows and columns accordingly. All my buttons are working except P1.00. I can use any other pin for  col 2  and it will work but for some reason not  P1.00.  It does not appear to be used anywhere else, and I don't get any warnings. Below is my Button_def.h and App.overlay files. I do need to use P1.00  as its the Keypad membrane header col 2.

Any suggestions would be welcomed. Thanks in advance 

app.overlay

/ {
    chosen {
        nordic,pm-ext-flash = &mx25r64;
    };
};

/ {
    chosen {
        /*
         * In some default configurations within the nRF Connect SDK,
         * e.g. on nRF52840 and nRF9160, the chosen zephyr,entropy node
         * is &cryptocell. This devicetree overlay ensures that default
         * is overridden wherever it is set, as this application uses
         * the RNG node for entropy exclusively.
         */
        zephyr,entropy = &rng;
    };
   //     vbatt {
   //        compatible = "voltage-divider";
   //        io-channels = <&adc 31>; // pin no of the ADC channel
           //output-ohms = <22000>;
           //full-ohms = <(560000 + 22000)>;
           //power-gpios = <&sx1509b 4 0>;
    //   };
     
    zephyr,user {
        io-channels = <&adc 7>;
 };
	//remember to check buttons_def.h for corresponding ports
//   for Dongle
rows {      
	compatible = "gpio-leds";
	
 //   row1: row_1 {
 //       gpios = <&gpio0 9 GPIO_ACTIVE_HIGH>;
//        label = "keypadrow1";
//    };
	row2: row_2 {
		gpios = <&gpio0 17 GPIO_ACTIVE_HIGH>;//1.00 //remember to change buttons_def
		label = "keypadrow2";
	};
	row3: row_3 {
		gpios = <&gpio0 20 GPIO_ACTIVE_HIGH>;//0.24//remember to change buttons_def
		label = "keypadrow3";
	};
	row4: row_4 {
		gpios = <&gpio0 22 GPIO_ACTIVE_HIGH>;//0.22//remember to change buttons_def
		label = "keypadrow4";
	};
 };
 
col {
	compatible = "gpio-keys";

	col1: col_1 {
		gpios = <&gpio0 24(GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;//0.20//remember to change buttons_def
		label = "keypadcol1";
	};
	col2: col_2 {
		gpios = <&gpio1 0 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;//0.17//remember to change buttons_def
		label = "keypadcol2";
	};
	col3: col_3 {
		gpios = <&gpio0 11 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;//0.15//remember to change buttons_def
		label = "keypadcol3";
	};
	col4: col_4 {
		gpios = <&gpio1 4 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; //0.13//remember to change buttons_def
		label = "keypadcol4";
	};
};


    pwmleds1 {
        compatible = "pwm-leds";
        status = "okay";

        pwm_led1: led_pwm_1 {
            status = "okay";
            pwms = <&pwm1 0 PWM_MSEC(20) PWM_POLARITY_INVERTED>;
            label = "LED Conn State";
        };
    };

    pwmleds2 {
        compatible = "pwm-leds";
        status = "okay";

        pwm_led2: led_pwm_2 {
            status = "okay";
            pwms = <&pwm2 0 PWM_MSEC(20) PWM_POLARITY_INVERTED>;
            label = "LED Caps Lock";
        };
    };

    pwmleds3 {
        compatible = "pwm-leds";
        status = "okay";

        pwm_led3: led_pwm_3 {
            status = "okay";
            pwms = <&pwm3 0 PWM_MSEC(20) PWM_POLARITY_INVERTED>;
            label = "LED Num Lock";
        };
    };
};

&pwm0 {
    status = "okay";
    pinctrl-0 = <&pwm0_default_alt>;
    pinctrl-1 = <&pwm0_sleep_alt>;
    pinctrl-names = "default", "sleep";
};

&pwm1 {
    status = "okay";
    pinctrl-0 = <&pwm1_default_alt>;
    pinctrl-1 = <&pwm1_sleep_alt>;
    pinctrl-names = "default", "sleep";
};

&pwm2 {
    status = "okay";
    pinctrl-0 = <&pwm2_default_alt>;
    pinctrl-1 = <&pwm2_sleep_alt>;
    pinctrl-names = "default", "sleep";
};

&pwm3 {
    status = "okay";
    pinctrl-0 = <&pwm3_default_alt>;
    pinctrl-1 = <&pwm3_sleep_alt>;
    pinctrl-names = "default", "sleep";
};

&pwm_led0 {
    status = "okay";
    pwms = <&pwm0 0 PWM_MSEC(20) PWM_POLARITY_INVERTED>;
    label = "LED System State";
};

&qspi {
    status = "disabled";
};

&pinctrl {
    pwm0_default_alt: pwm0_default_alt {
        group1 {
            psels = <NRF_PSEL(PWM_OUT0, 0, 13)>;
            nordic,invert;
        };
    };

    pwm0_sleep_alt: pwm0_sleep_alt {
        group1 {
            psels = <NRF_PSEL(PWM_OUT0, 0, 13)>;
            low-power-enable;
        };
    };

    pwm1_default_alt: pwm1_default_alt {
        group1 {
            psels = <NRF_PSEL(PWM_OUT0, 0, 14)>;
            nordic,invert;
        };
    };

    pwm1_sleep_alt: pwm1_sleep_alt {
        group1 {
            psels = <NRF_PSEL(PWM_OUT0, 0, 14)>;
            low-power-enable;
        };
    };

    pwm2_default_alt: pwm2_default_alt {
        group1 {
            psels = <NRF_PSEL(PWM_OUT0, 0, 15)>;
            nordic,invert;
        };
    };

    pwm2_sleep_alt: pwm2_sleep_alt {
        group1 {
            psels = <NRF_PSEL(PWM_OUT0, 0, 15)>;
            low-power-enable;
        };
    };

    pwm3_default_alt: pwm3_default_alt {
        group1 {
            psels = <NRF_PSEL(PWM_OUT0, 0, 16)>;
            nordic,invert;
        };
    };

    pwm3_sleep_alt: pwm3_sleep_alt {
        group1 {
            psels = <NRF_PSEL(PWM_OUT0, 0, 16)>;
            low-power-enable;
        };
    };
};

&adc {
    status = "okay";
};

&spi1 {
    status = "disabled";
};

&temp {
    status = "disabled";
};

&spi3 {
    status = "disabled";
};

&uart0 {
    status = "disabled";
};

&i2c0 {
    status = "disabled";
};



&gpio0 {
	status = "okay";
	gpio-reserved-ranges = <0 2>;
	gpio-line-names = "XL1", "XL2";
};

&gpio1{
	status = "okay";
	gpio-reserved-ranges = <0>;
	gpio-line-names = "";
};


&led3 {
    gpios = <&gpio0 6 GPIO_ACTIVE_LOW>;
};

&pwm3_default_alt {
    group1 {
        psels = <NRF_PSEL(PWM_OUT0, 0, 6)>;
    };
};

&pwm2_sleep_alt {
    group1 {
        psels = <NRF_PSEL(PWM_OUT0, 0, 6)>;
    };
};

&pwm3_sleep_alt {
    group1 {
        psels = <NRF_PSEL(PWM_OUT0, 0, 6)>;
    };
};

&pwm2_default_alt {
    group1 {
        psels = <NRF_PSEL(PWM_OUT0, 0, 8)>;
    };
};

&led2 {
    gpios = <&gpio0 8 GPIO_ACTIVE_LOW>;
};

&pwm2_sleep_alt {
    group1 {
        psels = <NRF_PSEL(PWM_OUT0, 0, 8)>;
    };
};

&pwm1_default_alt {
    group1 {
        psels = <NRF_PSEL(PWM_OUT0, 1, 9)>;
    };
};

&pwm1_default_alt {
    group1 {
        psels = <NRF_PSEL(PWM_OUT0, 0, 12)>;
    };
};

&led1 {
    gpios = <&gpio0 12 GPIO_ACTIVE_LOW>;
};

&pwm1_sleep_alt {
    group1 {
        psels = <NRF_PSEL(PWM_OUT0, 0, 12)>;
    };
};



&led0 {
    gpios = <&gpio1 9 GPIO_ACTIVE_LOW>;
};

&pwm0_default_alt {
    group1 {
        psels = <NRF_PSEL(PWM_OUT0, 1, 9)>;
    };
};

&pwm0_default {
    group1 {
        psels = <NRF_PSEL(PWM_OUT0, 0, 9)>;
    };
};

&pwm0_default {
    group1 {
        psels = <NRF_PSEL(PWM_OUT0, 1, 9)>;
    };
};

&pwm0_sleep {
    group1 {
        psels = <NRF_PSEL(PWM_OUT0, 1, 9)>;
    };
};

&pwm0_sleep_alt {
    group1 {
        psels = <NRF_PSEL(PWM_OUT0, 1, 9)>;
    };
};

&button0 {
    gpios = <&gpio0 29 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
};

&button1 {
    gpios = <&gpio1 7 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
};

&button2 {
    gpios = <&gpio1 5 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
};

&button3 {
    gpios = <&gpio1 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
};

 
buttons_def.h
/*
 * Copyright (c) 2021 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
 */

#include <caf/gpio_pins.h>

/* This configuration file is included only once from button module and holds
 * information about pins forming keyboard matrix.
 */

/* This structure enforces the header file is included only once in the build.
 * Violating this requirement triggers a multiple definition error at link time.
 */
const struct {} buttons_def_include_once;

static const struct gpio_pin col[] = {

    { .port = 1, .pin = DT_GPIO_PIN(DT_NODELABEL(col4), gpios) },//0.20 remember to look at the app over lay map
    { .port = 1, .pin = DT_GPIO_PIN(DT_NODELABEL(col2), gpios) },//0.17 remember to look at the app over lay map
    { .port = 0, .pin = DT_GPIO_PIN(DT_NODELABEL(col3), gpios) },//0.15 remember to look at the app over lay map
    { .port = 0, .pin = DT_GPIO_PIN(DT_NODELABEL(col1), gpios) },//0.13 remember to look at the app over lay map
  

};

static const struct gpio_pin row[] = {
    { .port = 0, .pin = DT_GPIO_PIN(DT_NODELABEL(button0), gpios) },
    { .port = 1, .pin = DT_GPIO_PIN(DT_NODELABEL(button1), gpios) },
    { .port = 1, .pin = DT_GPIO_PIN(DT_NODELABEL(button2), gpios) },
    { .port = 1, .pin = DT_GPIO_PIN(DT_NODELABEL(button3), gpios) },
// dont use row 1 for 12 button
  //  { .port = 0, .pin = DT_GPIO_PIN(DT_NODELABEL(row1), gpios) }, //0.09 remember to look at the app over lay map
    { .port = 0, .pin = DT_GPIO_PIN(DT_NODELABEL(row2), gpios) }, //1.00 remember to look at the app over lay map
    { .port = 0, .pin = DT_GPIO_PIN(DT_NODELABEL(row3), gpios) }, //0.24 remember to look at the app over lay map
    { .port = 1, .pin = DT_GPIO_PIN(DT_NODELABEL(row4), gpios) }, //0.20 remember to look at the app over lay map
};


Parents
  • Hello,

    You can download the schematic and layout from here if you haven't already:
    https://www.nordicsemi.com/Products/Development-hardware/nRF52840-Dongle/Download?lang=en#infotabs

    I don't see any reason why P1.00 should not be possible to use for any purpose no. If you just make a simple application toggling the IO, does that work? Maybe the pin have been damaged in some way?

    Kenneth

  • HI Kenneth, I have tried another board. same thing. I suspect it has something to do with the reserved pins.

    I initially had this problem with gpio0 .  I then unreserved as below but not sure I did it correctly with gpio1

    &gpio0 {
    	status = "okay";
    	gpio-reserved-ranges = <0 2>;
    	gpio-line-names = "XL1", "XL2";
    };
    
    &gpio1{
    	status = "okay";
    	gpio-reserved-ranges = <0>;
    	gpio-line-names = "";
    };
    

    The original device tree looked as follow

    &gpio0 {
    	status = "okay";
    	gpio-reserved-ranges = <0 2>, <6 1>, <8 3>, <17 7>;
    	gpio-line-names = "XL1", "XL2", "AREF", "A0", "A1", "RTS", "TXD",
    		"CTS", "RXD", "NFC1", "NFC2", "BUTTON1", "BUTTON2", "LED1",
    		"LED2", "LED3", "LED4", "QSPI CS", "RESET", "QSPI CLK",
    		"QSPI DIO0", "QSPI DIO1", "QSPI DIO2", "QSPI DIO3","BUTTON3",
    		"BUTTON4", "SDA", "SCL", "A2", "A3", "A4", "A5";
    };
    
    &gpio1 {
    	status = "okay";
    	gpio-line-names = "", "D0", "D1", "D2", "D3", "D4", "D5", "D6",
    		"D7", "", "D8", "D9", "D10", "D11", "D12", "D13";
    };

    Although nothing reserved in GPIO1 it does not allow me to toggle or read P1.00

  • Have you tried removing  gpio-reserved-ranges = <0>;?

    It's not a required property, and using it will likely, as you write, prevent it to be useable?

    Kenneth

  • Hi Kenneth, Apologies I have been trying to find where the P1.00 is being used.

    if I remove  gpio-reserved-ranges = <0>;? in the overlay it defaults to the .dts file which I don't want to edit. (original GPIO1 below)

    &gpio1 {
    	status = "okay";
    	gpio-line-names = "", "D0", "D1", "D2", "D3", "D4", "D5", "D6",
    		"D7", "", "D8", "D9", "D10", "D11", "D12", "D13";
    };
    

    As soon as I setup col2 P1.00. My entire program stops working. The keyboard is not detected via USB or BLE. I can use any other pin and it will work. 

    col2: col_2 {
    		gpios = <&gpio1 0 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;//0.17//remember to change buttons_def
    		label = "keypadcol2";
    	};

    Somewhere in the nrf_Dekstop keyboard  configuration example P1.00 must be reserved and I cant seem to find it

  • Okey, can I ask for one more test. Can you set it to something else than 0? Is there any pins on P1 not used for anything?

    Kenneth

  • I have tried P1.15, P1,13, P1.11  they all work and the program runs normally

Reply Children
  • Sorry, I was not clear. If you for instance set gpio-reserved-ranges = <15>;, is the problem then moved to P1.15? 

    Kenneth

  • No It is still the same. Looking at the below from the data sheet

    im wondering if it may have something to do with this

    &qspi {
    	status = "okay";
    	pinctrl-0 = <&qspi_default>;
    	pinctrl-1 = <&qspi_sleep>;
    	pinctrl-names = "default", "sleep";
    	mx25r64: mx25r6435f@0 {
    		compatible = "nordic,qspi-nor";
    		reg = <0>;
    		/* MX25R64 supports only pp and pp4io */
    		writeoc = "pp4io";
    		/* MX25R64 supports all readoc options */
    		readoc = "read4io";
    		sck-frequency = <8000000>;
    		jedec-id = [c2 28 17];
    		sfdp-bfp = [
    			e5 20 f1 ff  ff ff ff 03  44 eb 08 6b  08 3b 04 bb
    			ee ff ff ff  ff ff 00 ff  ff ff 00 ff  0c 20 0f 52
    			10 d8 00 ff  23 72 f5 00  82 ed 04 cc  44 83 68 44
    			30 b0 30 b0  f7 c4 d5 5c  00 be 29 ff  f0 d0 ff ff
    		];
    		size = <67108864>;
    		has-dpd;
    		t-enter-dpd = <10000>;
    		t-exit-dpd = <35000>;
    	};
    };

    I tried  CONFIG_FLASH=n in the prj_keyboard.conf. But then it does not compile as configuration is incomplete.

    I also tried disabling it in the overlay but it has no effect. 

    &qspi {
        status = "disabled";
    };

  • Sorry to ask a bit obvious question, but running for instance blinky or button example, you are able to control the P1.00 pin then yes?

    Kenneth

  • Hi Kenneth

     I ran the blink and push button samples on P1.00 with success. I then loaded the original NRF_desktop keyboard.conf example. Change button0 to P1.00 and that also worked.

    I made a copy of my project from a year ago sdk 2.4 and tool chain 2.4 changed the pins and it worked first time. 

    I will now complete the project then port it to SDK 2.6 and revert back. for now, I'm just glad I can move on.

    Thanks for you guys' assistance as always.

Related