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

nrf52-mesh-light-switch-client-server-proxy-master add uart module

HI

I use SDK nrf52-mesh-light-switch-client-server-proxy-master with nrf52840 PDK。

I need uart module,so I add include path,c file to the project.

add header file , uart_init function and uart event handle dunction to main.c . 

set SDKconfig.h as uart example of SDK15.0.0 .

At beginning,it works fine. But when I send many data or send data Very frequently, it will stop running and show this error:

app_error_weak.c,  105, Mesh error 1 at 0x00000000 (:0)

after debug, i fuond that uart_event_handle function came a event of APP_UART_COMMUNICATION_ERROR.

  • APP_UART_COMMUNICATION_ERROR

    From app_uart_evt_t :

    uint32_t app_uart_evt_t::error_communication

    Field used if evt_type is: APP_UART_COMMUNICATION_ERROR. This field contains the value in the ERRORSRC register for the UART peripheral. The UART_ERRORSRC_x defines from nrf5x_bitfields.h can be used to parse the error code. See also the nRF5 Series Reference Manual for specification.

    I need you to share the value of the UARTs ERRORSRC register.


    I suggest using HW Flow Control, or the UARTE — Universal asynchronous receiver/transmitter with EasyDMA peripheral with UARTE driver.

  • Hi haakonsh.

    thanks for your reply.

    I found these defines,

    /* Bit 3 : Break condition */
    #define UART_ERRORSRC_BREAK_Pos (3UL) /*!< Position of BREAK field. */
    #define UART_ERRORSRC_BREAK_Msk (0x1UL << UART_ERRORSRC_BREAK_Pos) /*!< Bit mask of BREAK field. */
    #define UART_ERRORSRC_BREAK_NotPresent (0UL) /*!< Read: error not present */
    #define UART_ERRORSRC_BREAK_Present (1UL) /*!< Read: error present */

    /* Bit 2 : Framing error occurred */
    #define UART_ERRORSRC_FRAMING_Pos (2UL) /*!< Position of FRAMING field. */
    #define UART_ERRORSRC_FRAMING_Msk (0x1UL << UART_ERRORSRC_FRAMING_Pos) /*!< Bit mask of FRAMING field. */
    #define UART_ERRORSRC_FRAMING_NotPresent (0UL) /*!< Read: error not present */
    #define UART_ERRORSRC_FRAMING_Present (1UL) /*!< Read: error present */

    /* Bit 1 : Parity error */
    #define UART_ERRORSRC_PARITY_Pos (1UL) /*!< Position of PARITY field. */
    #define UART_ERRORSRC_PARITY_Msk (0x1UL << UART_ERRORSRC_PARITY_Pos) /*!< Bit mask of PARITY field. */
    #define UART_ERRORSRC_PARITY_NotPresent (0UL) /*!< Read: error not present */
    #define UART_ERRORSRC_PARITY_Present (1UL) /*!< Read: error present */

    /* Bit 0 : Overrun error */
    #define UART_ERRORSRC_OVERRUN_Pos (0UL) /*!< Position of OVERRUN field. */
    #define UART_ERRORSRC_OVERRUN_Msk (0x1UL << UART_ERRORSRC_OVERRUN_Pos) /*!< Bit mask of OVERRUN field. */
    #define UART_ERRORSRC_OVERRUN_NotPresent (0UL) /*!< Read: error not present */
    #define UART_ERRORSRC_OVERRUN_Present (1UL) /*!< Read: error present */

    thanks for your suggestion, I will try.

  • Hi

    I got something new.

    I tried to modify FIFO BUFFER SIZE RX and TX to a maximum of 2048. I found that if sent and received 5 bytes per 200 ms. There will be no mistakes. But more than 5 bytes will make a mistake.
    In addition, I tried to modify the priority parameter in the function uart_init() to be high priority. There was no error every 200 ms when the test received and sent 20 bytes. The question now is whether changing priorities will have any other impact.

     APP_IRQ_PRIORITY_LOWEST-->APP_IRQ_PRIORITY_HIGH

  • I need you to define "a mistake",  I can not help you if I do not know the nature of your problem. 

    One thing that might solve your problems is using the UARTE — Universal asynchronous receiver/transmitter with EasyDMA peripheral with the UARTE driver in non-blocking mode with DMA. That way your UART communication is almost completely independent from the CPU. 

  • sorry for the later reply.

    "a mistake" means the error APP_UART_COMMUNICATION_ERROR as same as this question.

    my example used the uart with easyDMA but I don't know much about non-blocking

Related