Issue with the new UART configuration in zephyr RTOS for nrf52840dk

I have configured new UART in zephyr.dts device tree like this"
"/ {
        chosen {
            zephyr,console = &uart1;
            zephyr,shell-uart = &uart1;
            zephyr,uart-mcumgr = &uart1;
            zephyr,bt-mon-uart = &uart1;
            zephyr,bt-c2h-uart = &uart1;
            zephyr,sram = &sram1;
            zephyr,flash = &flash1;
            zephyr,code-partition = &slot1_partition;
            zephyr,ieee802154 = &ieee802154;
        };
    
        uart1: uart@40028000 {
            compatible = "nordic,nrf-uarte";
            reg = <0x40028000 0x1000>;
            interrupts = <0x28 0x1>;
            status = "okay";
            current-speed = <115200>;
            pinctrl-0 = <&uart1_default>;
            pinctrl-1 = <&uart1_sleep>;
            pinctrl-names = "default", "sleep";
        };
    };
    
    &uart1 {
        pinctrl-0 = <&uart1_default>;
        pinctrl-1 = <&uart1_sleep>;
        pinctrl-names = "default", "sleep";
    };
    
    &pinctrl {
        uart1_default: uart1_default {
            group1 {
                psels = <NRF_PSEL(UART_TX, 0, 14)>, /*Tx pin */
                        <NRF_PSEL(UART_RX, 0, 16)>; /*Rx pin */
            };
        };
    
        uart1_sleep: uart1_sleep {
            group1 {
                psels = <NRF_PSEL(UART_TX, 0, 14)>,
                        <NRF_PSEL(UART_RX, 0, 16)>;
            };
        };
    };
and i am using this UART as "const struct device *uart_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));" in my implementation,but my problem is that in this tx pin is working as i am able to see light in the tx pin when i send some data through external application,but I am not able to receive data from rx pin  means rx pin is not working so i am not getting how to solve the issue.

where i am using USB to ttl to connect tx and rx pin to the nrf52840dk board


Parents Reply Children
  • Yes, that is correct. There are some pins that are assigned physically on the nRF52840DK. It can't be rerouted in firmware and those are for instance the GPIOs used by the LED and buttons.

    You can send things to P0.14 (LED2) through TX and the LED should in theory light up when the UART line is high, but if you set your receiving line on P0.16, you've effectively set it up to receive a signal from a LED, which is why you don't see anything on the RX line.

    Kind regards,
    Andreas

  • How can I now find out which pins on the nrf52840dk board are unassigned?It is possible to configure a new UART with unassigned pins?

  • This reply explains this:

    AHaug said:
    You can find an overview over them on the backside of the DK or in the datasheet for the nRF52840DK.

    Have a look at chapter 4, and specifically 4.6 in the datasheet.

    Kind regards,
    Andreas

  • I did not find any of the freely available gpio pins.Can you help me with this

  • Yes I can, here's some pointers

    If you open the datasheet and navigate to Figure 20 in chapter 4.6 you will see an overview over the connectors on the nrf52840DK. It should look like this.

    Some of the GPIO's does only have a Pin number text, while others does have a grayed out text beside them. The ones that has a grayed out text beside them are GPIO's that have been wired physically on the DK to something on the DK. You will also find this same image and list of used and un-used GPIOs on the back side of the DK you're using.

    For instance, see that P0.13-0.16 are reserved for LEDs, while P0.09 and P0.10 are reserved for NFC, and the predefined UART that you can see in 3.2 that you can use for UART logging, or in the UART lesson in the academy. You can in some cases use the occupied GPIOs for other things, but that requires physical interference with the DK.

    Instead you should find a set of GPIO's that are not used. These are any of the GPIO's on P2, P3 and P4 and connect your devices that will communicate with each other over UART together with them.

    I will again recommend this lesson https://academy.nordicsemi.com/courses/nrf-connect-sdk-fundamentals/lessons/lesson-4-serial-communication-uart/ and when you feel comfortable, you can have a look at the peripheral and central UART samples which uses the Nordic UART Services (NUS) for BLE to communicate similar to UART but only over BLE.

    Kind regards,
    Andreas

Related