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

Application Code hangs after SUCCESSFULLY sending notification to central

Hi All. 

I am writing an application that has several notifiable characteristics, and up until now they have been sending data just fine, however the other day I was cleaning up some code and i decided to change the function that handles the notification process a little bit, make it more robust. I was previously just passing in the data i wanted to be sent along with its length and then inside the function deducing what characteristic handle was appropriate based on the length of the data, but then I should really just pass the appropriate handle along to the function also so i don't have to do all that deduction and can just point to the value thats' passed through. anyways Now the notification goes through to the central and they receive the data but a second or two later peripheral hangs on a hardfault (disassembly shows it is at address 0xa60) but i haven't the slightest Idea why. 

Some more background: I was initially calling the function from inside a timeout handler that interrupts every 100ms, and I saw in another post that that might be screwing with the softdevice so I moved the function call to inside main (call only happens when the appropriate flag has been raised). I still get the hardfault even when the call is in main and I can see from some debug lines that I have added that the notification call goes through fine, sd_ble_gatt_hvx returns NRF_SUCCESS, then the application runs through main 5-6 more times before the hardfault appears. Weird thing is I can perform other gatt operations just fine, writing and reading go off without a hitch.

Also, I dont think this is the issue but it may be relevant, these characteristics were previously indicatable instead of notifiable, but I believe I have changed the properties appropriately in the service initializer. Could this be the issue? could the softdevice be waiting for a confirmation from the central and then hang?

I am working with the nrff52832, using softdevice s132 V 6.1.1, sdk 15.3.0, and Segger Embedded Studio

Really at a loss on this one and any help that can be offered is appreciated.

 

Thanks,

Patrick

Parents
  • Hello,

    I can't think of any obvious reasons as to why the hardfault exception gets  triggered when you attempt to send notifications from your main loop. It also sounds like the issue is possibly not directly related to the hvx call iteself since it is returning back application. Anyway, I think my best suggestion to further troubleshoot is to include the HardFault handling library in your project and see if you could get some more details about what caused the fault.

    Steps to enable the Hardfault handling libary

    1. make sure the following two source files are included in the project:

          <file file_name="../../../../../../components/libraries/hardfault/hardfault_implementation.c" />
          <file file_name="../../../../../../components/libraries/hardfault/nrf52/handler/hardfault_handler_gcc.c" />

    2. Apply the following sdk_config.h settings to enable hardfault handler and RTT logging in debug terminal

    HARDFAULT_HANDLER_ENABLED 1
    NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED 0
    NRF_LOG_BACKEND_RTT_ENABLED 1
    

    3. Select the debug configuration to prevent the hardfault handler from performing a system reset.

    4. Optional: disable 'hardfault' breakpoint to prevent the debugger from halting inside the MBR's hardfault handler at 0xa60. Alternatively, you can press the "play" button to continue execution from this address.

    Best regards,

    Vidar

  • Thanks for the info! I enabled all of the macros and included the files in my project, but the NRF_ERROR_LOG statements still weren't being executed and I'm not sure why. I know I'm probably not supposed to but in the interest of time I switch the error log call in the for loop in hardfault_implementation to a printf() just to see which error log  I got and it printed this:

    "Cause: The processor has attempted to execute an instruction that makes illegal use of the EPSR."

    any thoughts on what this means?

    Thanks,

    Patrick

Reply
  • Thanks for the info! I enabled all of the macros and included the files in my project, but the NRF_ERROR_LOG statements still weren't being executed and I'm not sure why. I know I'm probably not supposed to but in the interest of time I switch the error log call in the for loop in hardfault_implementation to a printf() just to see which error log  I got and it printed this:

    "Cause: The processor has attempted to execute an instruction that makes illegal use of the EPSR."

    any thoughts on what this means?

    Thanks,

    Patrick

Children
Related