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

UART Stopping

We have noticed an issue when using the UART on our nRF51822 (SoftDevice = S130, nRF51_SDK_9.0.0_2e23562). Our Nordic app waits for commands on the UART and processes these commands when they come in. A Linux host app sends these commands periodically over RS-232 to do things like tell the Nordic app to scan for advertisers and reply with scanned devices. Commands were being processed fine for about 10 min before the UART stopped passing incoming commands to our Nordic app. After more closely referencing example apps, we added sd_app_evt_wait() calls between UART byte reads (app_uart_get() calls) and this seemed to fix the issue. We are unsure how this fixed the issue as examples did not clarify (specifically) the point of the sd_app_evt_wait() calls.

Is this expected behaviour? Our concern is that we may be working around an issue that might surface again when our devices are run in the field (e.g. maybe the UART will now stop passing incoming bytes after days and not minutes). If adding sd_app_evt_wait() makes sense as a fix, we will move on. Clarification as to how this call addresses the issue is appreciated.

Thanks in advance.

Parents
  • What is app_uart_get() doing before you add the app event waits? Is it returning an error code or not returning at all or what? The documentation for that function tells you that if there's no character to read then it returns an error code and will generate an event when a byte comes in. The event coming in would trigger sd_app_evt_wait() to return so I can see how putting them in might be working, however what you should be doing is reading the character, if one is returned, processing it, if it's an error returned, then use sd_app_event_wait()

    while( app_uart_get( .. ) != NRF_SUCCESS )
        sd_app_evt_wait()
    // process your character here
    

    more like that

Reply
  • What is app_uart_get() doing before you add the app event waits? Is it returning an error code or not returning at all or what? The documentation for that function tells you that if there's no character to read then it returns an error code and will generate an event when a byte comes in. The event coming in would trigger sd_app_evt_wait() to return so I can see how putting them in might be working, however what you should be doing is reading the character, if one is returned, processing it, if it's an error returned, then use sd_app_event_wait()

    while( app_uart_get( .. ) != NRF_SUCCESS )
        sd_app_evt_wait()
    // process your character here
    

    more like that

Children
No Data
Related