This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SDKv1.5.1 Blinky example with UART

Dear Nordic support,

i'm evaluating the Nordic nRF52840_Dongle with the SDK 1.5.1, inlucing Zephyr etc. I could successfully compile and load the Blinky-example (..\ncs\v1.5.1\zephyr\samples\basic\blinky\build_nrf52840dongle_nrf52840) and manipulated it.

Now i am really struggeling to add a UART (a real UART, no CDC-USB) connection to the dongle. I promise i've read so many documentation (Zephyr, K-Config, Device-Tree, Nordic-SDK...). But i can't find answers...

---

1.) On which pins at the dongle, can i map the UART RX and TX pins?! Normally on a microcontroller i have a bunch of options, in the Nordic docs it looks like i can map them anywhere, can I? Precisely this configuration is feasible

zephyr.dts --

...

        uart0: uart@40002000 {
            reg = < 0x40002000 0x1000 >;
            interrupts = < 0x2 0x1 >;
            status = "okay";
            label = "UART_0";
            compatible = "nordic,nrf-uarte";
            current-speed = < 0x1c200 >;
            tx-pin = < 0x1f >;
            rx-pin = < 0x1d >;
            rts-pin = < 0x00 >;
            cts-pin = < 0x00 >;

...

2.) In the docs and even in the video the pins are numbered like "30", "31" and so on. But the in ref-maunal and the schematic there ist port number AND the pin number , e.g 0.12, 1.15, how do i address 1.15, when i want to used it as a UART pin in the config overlay file?

3.) In the picture below, there is my code of the blinky example, including my attemps of using the UART via the zephyr-API. The Problem is, that the "device_get_binding" - function returns a NULL-pointer. I have no idea why. 

Thanks a lot.

Sören

Parents
  • Hi Sören,

    1.) On which pins at the dongle, can i map the UART RX and TX pins?! Normally on a microcontroller i have a bunch of options, in the Nordic docs it looks like i can map them anywhere, can I? Precisely this configuration is feasible

    Any digital GPIO pin can be used for UART. See Pin assignments.

    2.) In the docs and even in the video the pins are numbered like "30", "31" and so on. But the in ref-maunal and the schematic there ist port number AND the pin number , e.g 0.12, 1.15, how do i address 1.15, when i want to used it as a UART pin in the config overlay file?

    The pin numbers you provide is x if using P0.x and y + 32 if using P1.y.

    3.) In the picture below, there is my code of the blinky example, including my attemps of using the UART via the zephyr-API. The Problem is, that the "device_get_binding" - function returns a NULL-pointer. I have no idea why. 

    Have you enabled UART0 in prj.conf? You can refer to a sample that use UART, for instance nrf\samples\bluetooth\peripheral_uart\

    Einar

  • Hi Einar,

    thanks,

    1. and 2. are clear now.

    After i changed the proj.conf to:

    CONFIG_GPIO=y
    CONFIG_UART_INTERRUPT_DRIVEN=y
    CONFIG_SERIAL=y
    CONFIG_UART_ASYNC_API=y

    there is an address connected to the handler, but there is still now traffic on the pins (i used tx-pin = <0x14> and rx-pin = <0x18>). I've checked this with a logic analyser.

    As i understand it, i only need the uart_tx() function to send something, am i right? Or is there another config that i have to set.

    developer.nordicsemi.com/.../uart.html

    ==edit==

    ret = uart_tx(uart_0_handle, &message, sizeof(message), SYS_FOREVER_MS );

    returns -35 -> -ENOTSUP: If driver does not support getting current configuration. 

    Why the driver is not supported? Which driver is supported?

    Thanks,

    Sören

  • Hi Sören,

    When you use CONFIG_UART_ASYNC_API=y you also need to specify uarte in the device tree, so referring to nrf\samples\bluetooth\peripheral_uart\ again you can look at prj.overlay (simply copy that to your project).

  • Okay,

    after i copied the prj.overlay file in my project, it compiles no more...

    nrfx_config.h is missing...

    But, why do i have to copy a file prj.overlay in the project with the same content as the zephyr.dts file??? I think i don't have understoond this Config-File concept at all... and yes i have read the docs, multiple times!!!

    Content of prj.overlay:
    &uart0 {
        compatible = "nordic,nrf-uarte";
    };

    Content of zephyr.dts:

    ...

    uart0: uart@40002000 {
                reg = < 0x40002000 0x1000 >;
                interrupts = < 0x2 0x1 >;
                status = "okay";
                label = "UART_0";
                compatible = "nordic,nrf-uarte";
                current-speed = < 0x1c200 >;
                tx-pin = < 0x14 >;
                rx-pin = < 0x18 >;
                rts-pin = < 0x11 >;
                cts-pin = < 0x16 >;
            };

    ...

    This makes no sense to me, sorry.

    Sören

Reply
  • Okay,

    after i copied the prj.overlay file in my project, it compiles no more...

    nrfx_config.h is missing...

    But, why do i have to copy a file prj.overlay in the project with the same content as the zephyr.dts file??? I think i don't have understoond this Config-File concept at all... and yes i have read the docs, multiple times!!!

    Content of prj.overlay:
    &uart0 {
        compatible = "nordic,nrf-uarte";
    };

    Content of zephyr.dts:

    ...

    uart0: uart@40002000 {
                reg = < 0x40002000 0x1000 >;
                interrupts = < 0x2 0x1 >;
                status = "okay";
                label = "UART_0";
                compatible = "nordic,nrf-uarte";
                current-speed = < 0x1c200 >;
                tx-pin = < 0x14 >;
                rx-pin = < 0x18 >;
                rts-pin = < 0x11 >;
                cts-pin = < 0x16 >;
            };

    ...

    This makes no sense to me, sorry.

    Sören

Children
  • Hi Sören,

    I am sorry for the delay. Have you made any progress on this? If not, perhaps you can upload your project here so I can look at it and try to build it on my side?

    SoerenBirth said:
    But, why do i have to copy a file prj.overlay in the project with the same content as the zephyr.dts file???

    You do not, I did not spot that it was in there before. All should be good in this regard then (the prj.overlay is a overlay to the dts, in much the same as the prj.conf is a overlay for the Kconfig configuration, though it is unfortunately not well documented).

Related