GPIO conflict

I have a nRF9160DK board that is used for development of a custom nRF9160 board. The hardware designers have assigned GPIO P0.27 to be a general purpose output pin. This pin is also used as uart0_cts. when I try to toggle this pin with a simple test it does not work with the code shown below. If I use another pin such as P0.23 the pin toggles fine. I am assuming there is a pin conflict by assigning 2 things to the same pin. The boards are already manufactured with P0.27 as a general purpose output control pin. How can I get this to work? Is there something in the overlay file I need to add or remove?

    int test = 0;
    while(1)
    {
        printf("test GPIO BAT_MON_EN %d\r\n",test & 0x01);
        /* toggle test */

        /* set/clear test */
        if(test++ & 0x01)
        {
//          printf("set\r\n");
            gpio_pin_set(bat_mon_en_dev, BAT_MON_EN_DEV_PIN, 1);
        }
        else
        {
//          printf("clear\r\n");
            gpio_pin_set(bat_mon_en_dev, BAT_MON_EN_DEV_PIN, 0);
        }
        k_sleep(K_MSEC(1000));
    }
  • Hello,

    I agree that it is preferable not to change any of the SDK files. 

    The simple workaround is to do the change that you just did, but do it in the overlay file instead. Add something like this to your own overlay file:

    &pinctrl {
    	uart0_default: uart0_default {
    		group1 {
    			psels = <NRF_PSEL(UART_TX, 0, 29)>,
    				<NRF_PSEL(UART_RTS, 0, 23)>;
    		};
    		group2 {
    			psels = <NRF_PSEL(UART_RX, 0, 28)>,
    				<NRF_PSEL(UART_CTS, 0, 26)>;
    			bias-pull-up;
    		};
    	};
    
    	uart0_sleep: uart0_sleep {
    		group1 {
    			psels = <NRF_PSEL(UART_TX, 0, 29)>,
    				<NRF_PSEL(UART_RX, 0, 28)>,
    				<NRF_PSEL(UART_RTS, 0, 23)>,
    				<NRF_PSEL(UART_CTS, 0, 26)>;
    			low-power-enable;
    		};
    	};
    };

    I see that you tried to delete the node uart0 in your overlay file, but later in the same file, you state:

    / {
    	chosen {
    		zephyr,bt-uart=&lpuart;
            nordic,nus-uart=&uart0;
    	};
    };

    So without building and looking into your application, it is a bit difficult to say how this would behave.

    If you upload the entire project as a zipped folder, I can have a look. If that is not possible, can you please try to do that pin change in yoru prj.conf?

    Best regars,

    Edvin

  • Edvin

    I removed all other references to uart0 in prj.conf. The only reference to uart0 is the pinctrl above and an alias. The change worked perfectly. There are no changes to any V2.5.0 file now. Thank you for your help. I will test for a few days before we close it, but all should be OK. Pin 23/26 are defined but not used on the custom board.

  • Edvin

    this is working nicely. This can be closed. Thank you for your support.

  • I am glad to hear. Closing the ticket. I will be out of office for a couple of weeks soon. If anything related pops up, please open a new ticket, and someone will be able to handle it before I come back.

    Best regards,

    Edvin

Related