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

Ignore Frame and Break Error in UART Driver

Hello,

I am using a custom nRF52840 (SDK 14.2.0, SoftDevice S140) based board.

I am using the UART module and associated UART drivers.

Is there a way to ignore the Break and Frame errors in the driver, and not cause the UART to stop receiving? 

Specifically, I want to use read in and process a message frame, and ignore the break error which occurs after the message frame is read in.

According to Nordic UARTE documentation, "If there was a framing error (wrong stop bit), that specific byte will NOT be stored into Data RAM, but following incoming bytes will."

Is this valid for the UART too? And Is it possible to store that specific byte which had a frame/break error into Data RAM instead of discarding it?

Thanks,

Parents
  • Hi,

    Can you post exactly which UART module/driver you are using? Preferably the entire application/project.

    If you are using app_uart library, the HW errors are by default passed to the APP_ERROR_CHECK() in the event handler in the examples. You can prevent the application from doing this if you do not want this error to reset the chip.

    When using the UART peripheral, only a single byte is received at a time (a few more bytes can be received in the HW FIFO, but only 1 byte is read out of the peripheral at the time). You have to restart the reception after each byte, regardless of an error occurring or not.

    Best regards,
    Jørgen

Reply
  • Hi,

    Can you post exactly which UART module/driver you are using? Preferably the entire application/project.

    If you are using app_uart library, the HW errors are by default passed to the APP_ERROR_CHECK() in the event handler in the examples. You can prevent the application from doing this if you do not want this error to reset the chip.

    When using the UART peripheral, only a single byte is received at a time (a few more bytes can be received in the HW FIFO, but only 1 byte is read out of the peripheral at the time). You have to restart the reception after each byte, regardless of an error occurring or not.

    Best regards,
    Jørgen

Children
  • I have attached the files which are related the the UART function of my project. The whole project is quite large and complex. 

    nRFdevzone_upload.zip

    I am handling UART events in my own file rs485.c

    I don't want break error(floating RX line after last stop bit of a message frame is received) to arise in the first place. Is there a way to do that in software? 

  • You can only enable interrupts for all ERRORSRC error, or none. If you are using the nrf_drv_uart driver (this is used by the nrf_serial library that you use), the error checking is enabled by default and requires driver code change to disable. The error is detected by HW, and the ERRORSRC register will contain the error until it is cleared.

    It is possible to avoid passing break error to the event handler, but this also requires modifying the nrf_serial library:

    case NRF_DRV_UART_EVT_ERROR:
    {
    	uint32_t errorsrc = nrf_drv_uart_errorsrc_get(&p_serial->instance)
    	if(errorsrc < 0x07 || errorsrc > 0x08)
    	{
    		event_handler(p_serial, NRF_SERIAL_EVENT_DRV_ERR);
    	}
        break;
    }

    Note that the nrf_serial library does not clear the ERRORSRC register when an error is detected. You can do that using nrf_uarte_errorsrc_get_and_clear().

Related