This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

UART Service instant overflow

I'm trying to create a program that takes a stream of UART data at 115k baud streaming in and sends it over BLE as fast as possible. So far, I've

(1)Verified/ made some tweaks to the Nordic UART Service (NUS) and validated I can see the stream with the "nRF UART v2.0" app (2)Verified the APP_Template works (3)Worked to merge the NUS into the template so I can have peer management

I'm not seeing serial data with the nRF UART app on my Android device, however I see it with DEBUG level enabled in logging.

Update 2: It looks like nus_send is failing because of NRF_ERROR_INVALID_STATE. Even if I go into my nRF UART app and it says "Connected", this error persists. Any ideas?

Going into the ble_nus_string_send() function in debug, it definitely looks like this is happening because p_nus->conn_handle is showing BLE_CONN_HANDLE_INVALID, however it's not clear why this would be set.

Since it looks like I'm getting closer, I'm going to put most of the "old" info in quotes

I've managed to work past a few quirks, and now I can

  • Initialize UART/ NUS similar to the example
  • Initialize the NUS UUID (took some RAM tweaks in the linker file)
  • Connect to my phone as a peer... at first RTT Viewer showed last night:

0> APP:INFO:Light it up!

0> APP:INFO:Fast advertising.

0> APP:INFO:Connected to a previously bonded device.

0> APP:INFO:Local Cache applied

0> APP:INFO:Connected.

0> APP:INFO:Peer Update Succeeded

0> APP:INFO:Peer Update Succeeded

[The device would essentially just sit here with no activity. UART Classic would generate a fatal error]

0> APP:INFO:Disconnected.

However, now when I connect to the app via nRF UART v2.0, I see "Connected", but there's no activity. If I pause execution in eclipse, debugging points to a UART overrun (so far as I can tell from the attached image). I searched a few other questions, and the general thought was "there's too much going on to take a UART stream without flow control and manage BLE" - so I enabled eDMA and disabled legacy UART, in hopes that I could at least just pull what data I can out of memory, and then take a look at what UART data I may have lost and then tweak my code accordingly. ERRORSC.jpg Even with eDMA, I still seem to be running into errors when execution is paused. Interestingly, if I disconnect the other module's TX line, connect my phone via the nRF UART app, and then plug in the TX line, I instantly hit a UART overflow error (sometimes framing), and NUS doesn't even try to send.

Last night I disabled UART Legacy s

upport (traditional TX/ RX interrupts) and enabled eDMA. Here's the interesting part:

  • Setting NRF log level to DEBUG, I see my UART stream! The application comes up, broadcasts, and just sits there filling up the terminal with UART data.
  • When I connect with the UART app on my phone, it shows connected, but no UART data (even though it's still streaming across the screen in RTT Viewer)
  • Now when I try and pair with my phone, pairing to my Android device is rejected! Unplugging the UART (so I can see what's happening in terminal) I show:
  • 0> APP:INFO:Connected to a previously bonded device. 0> APP:INFO:Local Cache applied 0> APP:INFO:Connected. 0> APP:INFO:Security Rejected- already bonded 0> APP:INFO:Disconnected. 0> APP:INFO:Fast advertising. [Second attempt] 0> APP:INFO:Connected to a previously bonded device. 0> APP:INFO:Local Cache applied 0> APP:INFO:Connected. 0> APP:INFO:Security Rejected- already bonded 0> APP:INFO:Disconnected. 0> APP:INFO:Fast advertising.

When debugging using eDMA and , I only see UART errors when pausing the application (I assume the hardware is still running but can't transfer?). Not as concerned since I can see UART now, but I've copied that too. ERROR-eDMA.jpg Any ideas as to what's going on?

(Project info) SDK_13.1.0_7ca7556

S132 Soft Device

nrf52832

  • Hi,

    1. Can you try to set NRF_LOG_DEFAULT_LEVEL to 'Debug' in sdk_config.h so that maybe we can get some more detailed logging.
    2. If you leave the RX line on the nRF52 unconnected and floating in the wind it is pretty common to get UART errors because it picks up noise which registers as incoherent UART frames.
    3. Do you at any point, with RX connected or not, get any error info out of the UART event handler? The parameter passed into the handler might contain some valuable info. You can find the info in p_event->data.error_communication and/or p_event->data.error_code
    4. You say that "Debugging points to a UART overrun". Are there any specific clues that points to this?
    5. In your list of bullet points you list "Initialize UART" after you get the APP:INFO:Disconnected message. Is this correct and as intended?
  • @Martin I edited my post to account for most of your comment. The errors occur with UART connected, otherwise it seems to just hang out and connect to devices fine. I've added more detail on the errors and when they occur above.

    "Initialize UART" was just bad structure - that's just on the list of successful things

  • Found the answer - it's a little dumb..

    in ble_evt_dispatch it looks like I forgot to add the NUS! Naturally, it was never getting into a "connected" state

Related