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

sd_ble_gap_addr_get goes to "hardfault"

Hello, a little context first:

ble_gap_addr_t my_addr;
uint32_t error_code = NRF_SUCCESS;
error_code = sd_ble_gap_addr_get(&my_addr);

if (error_code != NRF_SUCCESS)
{
    return error_code;
}

Nothing out of the ordinary, except the program won't go pass this, and runs directly into the "hardfault", I put it in quote because it's not really real hardfault, but an error handler defined by the original programmer.

Now, I'm actually migrating this project from nrf51 to nrf52, and back in s110 it was completely fine, and quite unexpectedly,it became problematic in nrf52, S140.

Back to the "fake" hardfault function: I can't read the error_code, because the function sd_ble_gap_addr_get will enter the hardfault before exiting and yield the error code, also regrettably as this point I have no idea how to point the hardfault to the pack 13 version, located in app_error.h.

Now I know things looks kind of messy here, so a quick recap:

1.Migrating a project from nrf51 s110 to nrf52 s140

2.Program runs to the guilty section of the code, executes sd_ble_gap_addr_get and goes to an error handler defined by original author of the code

  1. As such, I'm unable to tell what went wrong at this point.

So what I'm trying to accomplish:

  1. Figure out what the problem is.

  2. No.1 can be achieved by somehow designating the error handler to the ones in app_error.h. If I use something like

    APP_ERROR_HANDLER(LOCAL_ERR_CODE);

I can enter the "right" error handler, but execution in the middle of a SD function? I don't know how.

So, can anyone please help me?

Edit, this is the "fake" error handler I was talking about, in main.c:

/**
* @brief General error handler.
*/
static void error_loop(void)
{

    __disable_irq(); /* Prevent the mesh from continuing operation. */
    while (true)
    {
        __WFE(); /* sleep */
    }
}

Edit #2: Maybe to execute sd_ble_gap_addr_get, you need some prerequisites, like you first have to initialize something else, which previously isn't required in nrf51 series?

Parents Reply Children
No Data
Related