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

Assertions in uarte driver due to framing and parity errors can't be overridden.

Hi,

I'm seeing frequent assertions the uarte driver (sdk/components/libraries/experimental_libuarte/nrf_libuarte_async.c) due to framing and parity errors.  These are expected since the pin is not always connected so I need to be able to handle them gracefully.  At the moment they hit the default condition in uart_evt_handler() and assert, there needs to be a user callback available so they can be handled gracefullly.

I'm using S132 and SDK 15.2 on an nrf52832.

Thanks,
Tom

  • Hello,

    Is the assert that you speak of the APP_UART_COMMUNICATION_ERROR in uart_event_handle() in main.c?

    If so, as you say, they are expected if you have some floating pins. What you can do is to not pass the p_event->data.error_communication into the APP_ERROR_HANDLER().

    If it is something else, can you please describe what sort of default condition you are speaking of?

    Best regards,

    Edvin

  • Hi Edvin,

    It's in nrf_libuarte_async.c in uart_evt_handler() at line 158.  The callback handles all the event types except NRF_LIBUARTE_EVT_ERROR.  I see framing errors assert here.

    Thanks,

    Tom

  • This one?

    I don't quite follow. Did you change anything in that file?

    Are you sure that you don't get the event forwarded to main.c?

    Maybe I misunderstood, but I can't see where you get the assert that you can't disable.

    Usually the framing errors are forwarded to the uart_event_handler with the event type APP_UART_COMMUNICATION_ERROR.

    BR,

    Edvin

  • Hi Edvin,

    It's a bit further down in that function, the event  NRF_LIBUARTE_EVT_ERROR ends up in the default case and asserts right there in the line I've highlighted in grey.

    Thanks,
    Tom

  • Ok. I see.

    To be honest, I haven't played around with any examples using this library. Is there a particular reason that you use this, and not the regular uart/uarte library that is used in e.g. the ble_app_uart example? This example will handle all UART events in main.c.

    However, if you want to use this library, you can remove the APP_ERROR_CHECK_BOOL(false); and replace it with your own handling. You can even add a separate event for the NRF_LIBUARTE_EVT_ERROR event, which is probably what you are receiving, since the only four possible event types for this handler are:

    typedef enum
    {
        NRF_LIBUARTE_EVT_RX_DATA,    ///< Data received.
        NRF_LIBUARTE_EVT_RX_BUF_REQ, ///< Requesting new buffer for receiving data.
        NRF_LIBUARTE_EVT_TX_DONE,    ///< Requested TX transfer completed.
        NRF_LIBUARTE_EVT_ERROR       ///< Error reported by the UARTE peripheral.
    } nrf_libuarte_evt_type_t;

    just add a:

    case NRF_LIBUARTE_EVT_ERROR:
        // do nothing
        break;

    before the default event.

    Best regards,

    Edvin

Related