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

Cannot read values over UART (libuarte_drv) on nRF52840-DK

Most of the examples and posts are about the libuarte async driver, but I am using the basic libuarte_drv (not async) and running into difficulty. Without any concrete example implementations I've based my development on the SDK's libuarte async example. I've attached an archive below including a simple Make project to reproduce the behaviour I am seeing. In the archive is also a README with more details and instructions but I'll outline the issue here as well.

My setup:

  •  Ubuntu 20.04
  •  GNU Make v4.2.1
  •  arm-none-eabi-gcc v10.2.1
  •  Nordic SDK v17.0.2
  •  nRF52840-DK
    •  bootloader: 0244_sam3u2c_bootloader_update_0x5000
    •  firmware: J-Link_OB-SAM3U128-V2-NordicSemi_170724
  •  Python v3.8.8

Use case:

I am trying to create an application that communicates with a host PC via UART, the host code is written in Python. The rest of the device-side application is in C++ so I've made my main file C++ instead of C to try and keep this minimal example realistic for my needs.

Problem:

I cannot seem to receive values from the host PC on the device, whenever I read from the rx buffer I just get zeros. I've tested the device tx and the host receives the correct values which narrowed it down to how I'm receiving/reading values on the device. I am assuming I have a problem in my config or how I am handleing the rx start/stop. I am also unclear if and where I need to use the nrf_libuarte_drv_rx_buf_rsp() function given this is not async.

Please take a look at the attached project. If there is nothing specific that jumps out I would also appreciate some debug tips or tool suggestions!

minimal_uart.zip

Thank you!

Parents
  • I recommend to use libUARTE async library, you can still use hardware flow control if you like with that one. Are you able to send and receive data when using the libuarte example?

    If you want to use the libUARTE driver directly, then you need to look for instance at the libUARTE library for example usage and the documentation for libUARTE driver:
    https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/group__app__common.html

    Have you checked if your callback handler in nrf_libuarte_async_init() is triggered and which events are occuring?

    Have you checked on a logic analyzer trace which data is sent and received on the UART?

    Kenneth

  • Hi Kenneth,

    Yes I am able to successfully use the async driver. I have a simple application and figured I didn't need the added complexity so I tried using the underlying synchronous driver but I can just use the async driver and use the event handler to manage the behaviour.

    I will note that the async example uses a buffer length of 255 which would hang after a while. I didn't investigate why but using a buffer length that is a power of 2 fixes the problem.

    Also for posterity and anybody else that comes across this:

    Have you checked if your callback handler in nrf_libuarte_async_init() is triggered and which events are occuring?

    I wasn't aware I needed this function if not using the async driver?

    Have you checked on a logic analyzer trace which data is sent and received on the UART?

    I monitored values sent across the serial line and the host side was sending the expected values, the problem appears to have been receiving them on the device side.

Reply
  • Hi Kenneth,

    Yes I am able to successfully use the async driver. I have a simple application and figured I didn't need the added complexity so I tried using the underlying synchronous driver but I can just use the async driver and use the event handler to manage the behaviour.

    I will note that the async example uses a buffer length of 255 which would hang after a while. I didn't investigate why but using a buffer length that is a power of 2 fixes the problem.

    Also for posterity and anybody else that comes across this:

    Have you checked if your callback handler in nrf_libuarte_async_init() is triggered and which events are occuring?

    I wasn't aware I needed this function if not using the async driver?

    Have you checked on a logic analyzer trace which data is sent and received on the UART?

    I monitored values sent across the serial line and the host side was sending the expected values, the problem appears to have been receiving them on the device side.

Children
No Data
Related