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

How can I find source of problem?

Hi !

I'm trying to debug. I followed this video : https://www.youtube.com/watch?v=uP8RYgYGRvI&list=PLx_tBuQ_KSqGHmzdEL2GWEOeix-S5rgTV&index=7 .  But I can't completely.

the program stop at NRF_BREAKPOINT_COND in app_error_weak.c.

I used breakpoint to understand which function the error occurred after.  I guess there is a problem when setting Uart. What should I do to better interpret the problem? What can be the problem ?

The program enters the following functions respectively:

1- nrf_drv_uart_init(...);

2- nrfx_uart_init(....);

3- interrupts_enable(....)

4- NRFX_IRQ_PRIORITY_SET(nrfx_get_irq_number((void *)p_instance->p_reg), interrupt_priority);

5- nrfx_get_irq_number(.....)

I added the 5 step's photos to explain better

1)

2)

3)

4)

5)

after step 5, the program stop at at NRF_BREAKPOINT_COND in app_error_weak.c

Parents
  • Hello,

    Are you working on an example from the SDK? If so, which example is this?
    Are you using the RTT or UART logger backend?

    Could you also confirm for me that you have DEBUG defined in your preprocessor defines, like shown in the included image?

    This will print a detailed error message to your logger output, if a non-NRF_SUCCESS error is passed to an APP_ERROR_CHECK.

    Looking forward to resolving this issue together!

    Best regards,
    Karl

  • In fact, this is a project developed on ble_peripheral example. It is not an example of UART or RTT.

     

    Are you using the RTT or UART logger backend?

    Is this what you mean? actually, I do not have information on this subject:

    Could you also confirm for me that you have DEBUG defined in your preprocessor defines, like shown in the included image?

    the current settings are like this, what should I do ?

  • Hi,

    If you were using interrupt priority 0 for your UART, then that would definitely be a problem, yes.
    Now you are using the NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY, is this still the default value, or have you modified this? 

    I did not change it. it is 6 by default.

    It seems the error is triggered at line 299 of your 'timer_init.c' file. Which function is being called here? Could you also share the entire function being executed in line 299 of timer_init.c, so I may take a look?

    I forgot to return the error code value for the function that caused the error. I fixed it. the error code is:

    <error> app: ERROR 8 [NRF_ERROR_INVALID_STATE] at D:\1_1_xxx_xxx_xxx\V.1.5.9_CML\V1.5.9\V1.5.9\examples\xxx_ble_peripheral\XXX_Project\timer_init.c:299
    PC at: 0x000335C7
    <error> app: End of error report

    The codes in the relevant line are as follows:

    also when I cancel this line, it gives the same warning for line 285:

    I guess there was a problem while creating the timers.I use 5 more timers other than these two timers. however, there was no such problem for them.

    but how can i solve this? 

  • Hello,

    cemalb said:
    I did not change it. it is 6 by default.

    Thank you for confirming. 

    cemalb said:
    I forgot to return the error code value for the function that caused the error. I fixed it. the error code is
    cemalb said:
    The codes in the relevant line are as follows:
    cemalb said:
    but how can i solve this? 

    When an error code is returned from a function, you should always check the functions API reference to determine the cause of the error. In this case, the app_timer_start function documentation about the returned error reads:

    NRF_ERROR_INVALID_STATE If the application timer module has not been initialized or the timer has not been created.

    So, you have either not initialized the timer module, or created this particular timer you are trying to use. Since your other timers are working as intended, I would think the latter is the case here.
    Please check that you have created the two timers in question, prior to attempting to start them.

    Best regards,
    Karl

  • Hi,

    Please check that you have created the two timers in question, prior to attempting to start them.

    I already start all timers with the timers_init() function inside the main() function.

  • Hello again,

    cemalb said:
    I already start all timers with the timers_init() function inside the main() function.

    No, you currently attempt to start all the timers. You never actually check whether you were successful in doing so or not.
    You are not checking any of the error codes returned from all your calls to app_timer_create.
    Please always check the API reference / documentation of functions you are using that you have not written yourself - such as SDK functions - before using them, and please always check the returned error codes of functions you end up using in your code.
    If you do not check the returned error codes, you will have no way of knowing whether a function call has failed for whatever reason, or if you application to could proceed as usual.
    Checking the returned error codes is crucial - it is also why we have taken the time to implemented them in the first place.

    Please add error code checks to all functions currently missing them, see what error code is being returned by the functions, and then check the API Reference to see why the function call failed.
    Do this, and let me know if it resolves your issue.

    Looking forward to resolve these issues together.

    Best regards,
    Karl

  • Hi, I replied late because I had to deal with other projects.

    Please add error code checks to all functions currently missing them, see what error code is being returned by the functions, and then check the API Reference to see why the function call failed.

    While creating timers, I added error codes for all of them, but they didn't return any error codes. they all return 0.

Reply Children
  • cemalb said:
    I replied late because I had to deal with other projects.

    No problem at all - we continue whenever you have the chance! :) 

    cemalb said:
    While creating timers, I added error codes for all of them, but they didn't return any error codes. they all return 0.

    I am happy to see that you have added this!
    Please make sure to add APP_ERROR_CHECK to all places where it is appropriate in your code,
    not just the timer_init function.

    So they all return successfully, that is good news!
    Are you still getting the NRF_ERROR_INVALID_STATE returned from your two app_timer_start calls, or has that too disappeared? If so, what error code is being returned currently?

    Best regards,
    Karl

  • Please make sure to add APP_ERROR_CHECK to all places where it is appropriate in your code,
    not just the timer_init function.

    Ok, I will add immediately.

    Are you still getting the NRF_ERROR_INVALID_STATE returned from your two app_timer_start calls, or has that too disappeared? If so, what error code is being returned currently?

    I guess the error has changed. the last error is:

    <error> app: ERROR 536907338 [Unknown error code] at XXX\V1.5.9\examples\btc_ble_peripheral\xxxBluetooth\timer_init.c:377
    PC at: 0x000336CB
    <error> app: End of error report

  • cemalb said:
    Ok, I will add immediately.

    Great! If you now see that the previous developer never checked any error codes you might have to review your whole project for this, but rest assured that it is essential to check error codes to know whether a function has completed successfully or not.

    cemalb said:

    I guess the error has changed. the last error is:

    <error> app: ERROR 536907338 [Unknown error code] at XXX\V1.5.9\examples\btc_ble_peripheral\xxxBluetooth\timer_init.c:377
    PC at: 0x000336CB
    <error> app: End of error report

    What function is being called at line 377 of your timer_init.c file?
    Keep in mind that I do not have you project, so there is no way for me to know what is happening here unless you tell me.
    Please also share the snippet of code of the function containing line 377 of timer_init.c.

    Best regards,
    Karl 

Related