This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEBUG flag, error module, nrf52

Hi, it's probably a very dumb question, but i don't seem to find any details about it. In nrf52 SDK documentation, in Error Module section it says

The behavior of the error handler differs depending on whether the DEBUG flag is set: If the DEBUG flag is not set: When app_error_handler is invoked, the MCU is reset. If the DEBUG flag is set: When app_error_handler is invoked, the function parameters (error code, line number, and > > file name) are copied to global memory, interrupts are disabled, and the application enters an > infinite loop.

So how do i set the DEBUG flag ? Where do i find it ? is it set automatically when i use debug function ?

I'm programming in Keil v5, the code builds fine but i need to troubleshoot it.

Thanks !

Parents
  • Hi,

    Don't worry. It's not a dumb question if our docs does not explain this correct.

    A better explanation would be something like "In order to enable blocking asserts with debug information, please ensure that the preprocessor symbol 'DEBUG' is defined in your project settings".

    In order to set this, you need to enter your Keil project settings, which is accessible from Keil uVision editor, "Options for target ".

    You shall now get a pop up, and go to the tab "C/C++", like shown in this link: www.keil.com/.../ide_prj_options.asp

    There's a ton of other defines there as well (NRF52 etc.), just add "DEBUG" to the "Define" field, and recompile/flash your device and you'll have blocking asserts instead of a reset-loop.

    When you enter debug mode, place a break point at this line in app_error.c::app_error_handler():

    while(loop)
    

    If you break at this loop, it means that an assert has occurred. You can then watch the "m_" prefixed variables to get the m_file_name/m_line_num/m_err_code.

    If you're stuck and cannot find the source of the issue, open a new case here in devzone and post the output of the assert debug message. Hopefully, you'll not see many asserts occurring.

    Have fun developing with the nRF52-series! :-)

    Cheers, Håkon

Reply
  • Hi,

    Don't worry. It's not a dumb question if our docs does not explain this correct.

    A better explanation would be something like "In order to enable blocking asserts with debug information, please ensure that the preprocessor symbol 'DEBUG' is defined in your project settings".

    In order to set this, you need to enter your Keil project settings, which is accessible from Keil uVision editor, "Options for target ".

    You shall now get a pop up, and go to the tab "C/C++", like shown in this link: www.keil.com/.../ide_prj_options.asp

    There's a ton of other defines there as well (NRF52 etc.), just add "DEBUG" to the "Define" field, and recompile/flash your device and you'll have blocking asserts instead of a reset-loop.

    When you enter debug mode, place a break point at this line in app_error.c::app_error_handler():

    while(loop)
    

    If you break at this loop, it means that an assert has occurred. You can then watch the "m_" prefixed variables to get the m_file_name/m_line_num/m_err_code.

    If you're stuck and cannot find the source of the issue, open a new case here in devzone and post the output of the assert debug message. Hopefully, you'll not see many asserts occurring.

    Have fun developing with the nRF52-series! :-)

    Cheers, Håkon

Children
  • Thanks a lot Hakon, really helpful answer!!! I've come across this before on other platforms, just didn't remember about it for some reason. I guess documentation could be a bit more specific.

  • Hi, I am using saadc example on SDK13 with IAR, and I can not find how to prepare debug and where to see debug result. Somewhere is written I can see the log or debug result through USB port witch I am programming, with a terminal like Putty. In that terminal I just can see "APP:INFO:Blinky example started." and ":ERROR:Fatal".

    I did this change, (options --> C/C++ Compiler --> add DEBUG at the end of Defined symbols box) but after that I got the warning of "The stack pointer for stack "CSTTACK" is outside the stack range".

    The main problem is that I have no result form the example and would like to know where and why the example is stocked.

Related