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.

Parents
  • 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

  • What is the value of data field of the app_uart event? From app_uart.h :

    /**@brief Struct containing events from the UART module.
     *
     * @details The app_uart_evt_t is used to notify the application of asynchronous events when data
     * are received on the UART peripheral or in case an error occured during data reception.
     */
    typedef struct
    {
        app_uart_evt_type_t evt_type; /**< Type of event. */
        union
        {
            uint32_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 \nRFXX Series Reference Manual for specification. */
            uint32_t error_code;          /**< Field used if evt_type is: NRF_ERROR_x. Additional status/error code if the error event type is APP_UART_FIFO_ERROR. This error code refer to errors defined in nrf_error.h. */
            uint8_t  value;               /**< Field used if evt_type is: NRF_ERROR_x. Additional status/error code if the error event type is APP_UART_FIFO_ERROR. This error code refer to errors defined in nrf_error.h. */
        } data;
    } app_uart_evt_t;


    Non-blocking means that you continue executing code when you wait for a state change instead of blocking execution: 
    change_state();
    
    while(!state_changed); // Blocking function 
    
    do_stuff();
    
    do_other_stuff(); // Blocked function
    
    -------------------------- VS ----------------------------
    
    change_state();
    do_other_stuff(); // Not blocked
    
    
    void some_event_handler(bool state_changed) 
    {
        if(state_changed)
        {
            do_stuff();
        }
    }

Reply
  • What is the value of data field of the app_uart event? From app_uart.h :

    /**@brief Struct containing events from the UART module.
     *
     * @details The app_uart_evt_t is used to notify the application of asynchronous events when data
     * are received on the UART peripheral or in case an error occured during data reception.
     */
    typedef struct
    {
        app_uart_evt_type_t evt_type; /**< Type of event. */
        union
        {
            uint32_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 \nRFXX Series Reference Manual for specification. */
            uint32_t error_code;          /**< Field used if evt_type is: NRF_ERROR_x. Additional status/error code if the error event type is APP_UART_FIFO_ERROR. This error code refer to errors defined in nrf_error.h. */
            uint8_t  value;               /**< Field used if evt_type is: NRF_ERROR_x. Additional status/error code if the error event type is APP_UART_FIFO_ERROR. This error code refer to errors defined in nrf_error.h. */
        } data;
    } app_uart_evt_t;


    Non-blocking means that you continue executing code when you wait for a state change instead of blocking execution: 
    change_state();
    
    while(!state_changed); // Blocking function 
    
    do_stuff();
    
    do_other_stuff(); // Blocked function
    
    -------------------------- VS ----------------------------
    
    change_state();
    do_other_stuff(); // Not blocked
    
    
    void some_event_handler(bool state_changed) 
    {
        if(state_changed)
        {
            do_stuff();
        }
    }

Children
No Data
Related