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

UART transaction trigger app_error_handler

Hi,

I'm using the 3rd generation of nRF51822 with S110 v8.0.0 and the SDK 10.0. In my application i'm using the uart core to communicate with the external device. I'm using the following code to initialize the UART core

void UART_INIT (void)
{
		
    uint32_t                     err_code;
    const app_uart_comm_params_t comm_params =
    {
        UART_RX_PIN_NUMBER,
        UART_TX_PIN_NUMBER,
        0,
        0,
        APP_UART_FLOW_CONTROL_DISABLED,
        false,
        UART_BAUDRATE_BAUDRATE_Baud57600
    };

    APP_UART_FIFO_INIT( &comm_params,
                       UART_RX_BUFFER_SIZE,
                       UART_TX_BUFFER_SIZE,
                       uart_event_handle,
                       APP_IRQ_PRIORITY_LOW,
                       err_code);
    APP_ERROR_CHECK(err_code);		   		  		  		   		
}	

The application works for a while (send and receive successfully) and suddenly it trigger the app_error_handler function.

The app_error_handler indicate that the error comes from nrf_drv_uart.c in line 0x100.

When i check the line 0x100 i see that the

ASSERT(m_cb.state == NRF_DRV_STATE_INITIALIZED);

line is causing the problem. i debug the program and noticed that the value of m_cb.state is 0x54 at the time that error is occurred.

I have no idea how to solve the problem.

Please let me know if any more information you need to assist me to solve the problem.

    1. It must be memory corruption as mb_state cannot have value 0x54. It If you are using Keil, then create a breakpoint on write access to mb.state in nrf_drv_uart.c. You will then know what has changed this value.

    2. Check to see if this behavior is same if you do not use softdevice (I mean disable the softdevice and run your application).

  • The value of the m_cb.state is only changing when the nrf_drv_uart_init function is called and it will set the value of m_cb.state to NRF_DRV_STATE_INITIALIZED

    It is not possible to turn off the Softdevice since there is too many functions rely on the Softdevice to work in my code

  • The fact that you said this driver worked for some time and then this variable gets this value is a clear sign of memory corruption. If you cannot disable the softdevice then try the conditional breakpoint feature in keil.

  • I set a breakpoint in the keil to break when the application is accessing the m_cb.state

    i noticed that the value is changing in one of my timers which is doing some string manipulation using strcat function.

    The string manipulation has nothing to do with the UART, I'm so confused.

  • looks like strcat is writing to some pointer uninitialized!!?? not sure what to say, can you post the code for the timer function that is doing strcat? Also I assume that you are debugging without any compiler optimizations, else I would not trust the breakpoints.

1 2