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

My device is freezing and restarting

My device is either freezing or restarting, and i do not know why.

Parents
  • Why?

    In the SDK examples, we check return codes with the macro APP_ERROR_CHECK. This function calls the function app_error_handlerin app_error.c. Here we find this code:

    #ifndef DEBUG
        NVIC_SystemReset();
    #else
    

    This means that by default, the response to ANY return code other than NRF_SUCCESS will cause a system reset.

    If we have defined DEBUG, this happens:

    m_error_code = error_code;
    m_line_num = line_num;
    m_p_file_name = p_file_name;
    UNUSED_VARIABLE(m_error_code);
    UNUSED_VARIABLE(m_line_num);
    UNUSED_VARIABLE(m_p_file_name);
    __disable_irq();
    while(loop);
    

    We disable interrupts and stay in a loop forever. In this case we can either print out or read (with a debugger) the error code, line number and file name that returned the error code.

    Note the warning in the documentation of app_error_handler:

    @warning This handler is an example only and does not fit a final product. You need to analyze * how your product is supposed to react in case of error.

    Finding the error with the Keil debugger:

    1.Set optimization level 0 in target options -> C/C++ and define DEBUG in the preprocessor symbols. image description

    2.Place a break point next to while(loop); (right click ->Insert breakpoint)

    3.Run the program, and wait for the error to occur.

    4.Read the information by hovering the mouse cursor over the value. Alternatively you can add the values to a watch by doing right click->add to watch X. To display the values in decimal format rather than in hexadecimal, right click the variable (in watch window) and click on "Hexadecimal Display".

    image description

    Find more information about debugging with Keil here.

  • If you take a look at the Call Stack, you'll see from which function call the error originated and then you'll have to refer to the documentation of that function on Infocenter. The error codes returned by our drivers/libraries are usually global error codes, i.e. one of the error codes listed here. Note: The link is specific to S132 v4.0.2, if you're using another SD, then you should look up the global error codes for the SD you're using.

Reply
  • If you take a look at the Call Stack, you'll see from which function call the error originated and then you'll have to refer to the documentation of that function on Infocenter. The error codes returned by our drivers/libraries are usually global error codes, i.e. one of the error codes listed here. Note: The link is specific to S132 v4.0.2, if you're using another SD, then you should look up the global error codes for the SD you're using.

Children
No Data
Related