How to configure the Second UART port in the nRF52840 DK?

Hello,

Currently, I am working on the nRF 52840 DK and the UART port named uart0 is connected to the on board debugger, Where do i find the pins for the UART1 ? I could not able to figure it out. Please let me know how can we do this?

  • HI Teja,

    The default pin settings can be found in the DTS file.. It

    Regards,

    Swathy

  • Hi SwRa,

    Here is my project configuration

    When, I looked at the Device tree DTS file of nrf52840, the uart1 is set to arduino_serial


    arduino_serial: &uart1 {
        current-speed = <115200>;
        pinctrl-0 = <&uart1_default>;
        pinctrl-1 = <&uart1_sleep>;
        pinctrl-names = "default", "sleep";
    };

    And the pin configuration is as follows

        uart1_default: uart1_default {
            group1 {
                psels = <NRF_PSEL(UART_RX, 1, 1)>;
                bias-pull-up;
            };
            group2 {
                psels = <NRF_PSEL(UART_TX, 1, 2)>;
            };
        };

    The pins for UART1 is set to

               RX -  P1.01

               TX  - P1.02

    In case if i want to enable RTS and CTS, which pins should i configure?

    For my board, I created a device overlay file and want to enable UART1 in the overlay file. The following lines has been added.

    / {
        my_uart: &uart1 {
            compatible = "nordic,nrf-uarte";
            status = "okay";
            current-speed = <115200>;
            pinctrl-0 = <&uart1_default>;
            pinctrl-1 = <&uart1_sleep>;
            pinctrl-names = "default", "sleep";
        };
    };

    After all the settings, when i build the project, the build fails with following error

    nrf52840dk_nrf52840.overlay:14 (column 14): parse error: expected node or property name

    Do i just need to add the same settings that arduino_serial has in the overlay to configure it? Could you please suggest me how to configure this correctly?

    Thanks & Regards

    Teja

  • Hi Teja,

    Teja_K said:
    nrf52840dk_nrf52840.overlay:14 (column 14): parse error: expected node or property name

    The error you're seeing suggests that there's a syntax issue in your overlay file.

    For enabling RTS and CTS, you can choose any pins that are free and not being used for any other functions.. Here's a simple overlay file that you can refer:

    &pinctrl {
        uart1_default: uart1_default {
            group1 {
                psels = <NRF_PSEL(UART_TX, 1, 2)>,
                        <NRF_PSEL(UART_RX, 1, 1)>,
                        <NRF_PSEL(UART_RTS, 0, 14)>,
                        <NRF_PSEL(UART_CTS, 0, 15)>;
            };
        };
    
        uart1_sleep: uart1_sleep {
            group1 {
                psels = <NRF_PSEL(UART_TX, 1, 2)>,
                        <NRF_PSEL(UART_RX, 1, 1)>,
                        <NRF_PSEL(UART_RTS, 0, 14)>,
                        <NRF_PSEL(UART_CTS, 0, 15)>;
                low-power-enable;
            };
        };
    };
    
    &uart1 {
        compatible = "nordic,nrf-uarte";
        status = "okay";
        current-speed = <115200>;
        pinctrl-0 = <&uart1_default>;
        pinctrl-1 = <&uart1_sleep>;
        pinctrl-names = "default", "sleep";
        hw-flow-control;
    };

    Remember, when using an overlay, you don't need to redefine the entire Uart1 node. You can simply modify the existing one as shown above. For more details on configuring uart and pincntrl in devicetree, you can refer: https://docs.nordicsemi.com/bundle/ncs-latest/page/zephyr/boards/nordic/nrf52840dk/doc/index.html#changing_uart1_pins 

    Best Regards,

    Swathy

Related