Simple UART using DK nrf52832

I am new to Zephyr and I have been trying to get hold of a tutorial or a sample app that would indicate how I can use the UART on the nRF52832 for communications with another device.

I am using v1.9.99 nRF Connect SDK. 

I have been looking at the KConfig file in VSCode and have manged to tick the right boxes (Hello World app), but getting the APIs to work is where I am stuck,

Any help will be appreciated.

Cheers

Parents Reply Children
  • Hi Dejan

    Thanks for the quick reply.

    That link for the UART example is helpful.

    Wanted to know the difference between the UART driver and the NCS UART driver in the KConfig file.

  • Hi,

    Zephyr uses 3 main methods for accessing UART peripheral - through polling, interrupts and asynchronously.
    You can read more about Zephyr UART, Zephyr UART API reference, Zephyr UART interface. and Zephyr device driver model.
    Zephyr UART driver example can be found here.
    In the first above-mentioned link, you can read about available configuration options for the standard UART driver.

    The low power UART driver is implemented on top of the standard UART driver. As described in the documentation, low power UART driver implements 2 control lines ()request - REQ and ready - RDY) instead two HW flow control lines thereby enabling low power mode. The same documentation provides the link to the configuration options which are available for low power UART driver.

    Best regards,
    Dejan

  • Thanks for the detailed reply. I have been looking into Zephyr documentation and it has information I am after.

    As a follow up question, how does the UART definition in the DTS/Overlay map to the UART APIs? I see in the documentation there are configuration APIs for pin mapping and strucutures for configuration of the UART itself, which duplicates the DTS configurations

    In the Simple UART example the call to device_get_binding() passes a string to a UART, I am guessing it then uses the UART configuration in the DTS file.

  • Hi,

    When using UART, one of the APIs needs to be chosen. For example, choosing async API requires CONFIG_UART_ASYNC_API=y configuration option (in addition to CONFIG_SERIAL=y). An UART peripheral is defined using struct device
    const struct device *uart= device_get_binding(DT_LABEL(DT_NODELABEL(uart0)));

    In this example uart is the pointer which interacts with UART API. In the devicetree, uart0 would be the name of the devicetree node used which represents UART hardware controller on the chip. You can read more about the devicetree here.

    Best regards,
    Dejan

Related