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

NRF_SDH_SOC_OBSERVER not running handler

I tried the following code:

In main:

void sys_dispatch_handler(uint32_t sys_evt, void * p_context)
{
test(sys_evt);
}

And registered the handler as follows:

NRF_SDH_ANT_OBSERVER(..............) ;(this works)

NRF_SDH_SOC_OBSERVER(sys_ant_observer, NRF_SDH_STACK_OBSERVER_PRIO_LEVELS,sys_dispatch_handler, NULL);

I tried priority 0 and 1. 

The code compiles, runs,with an ANT+ device,,  but the test(sys_evt) never gets executed regardless of events.

I'm using SDK v16,0.0 SD332

Parents
  • Hi,

    Please verify that the 'nrf_sdh_soc.c' is included in your build. This file implements the STACK OBSERVER responsible for forwarding system events to the NRF_SDH_SOC_OBSERVERs. Also, if you can add the code line below after enabling the Softdevice to ensure there is at least one SoC event source.

        /* Request Softdevice to turn on Crystal oscillator to test if SoC events are
           forwarded to the application. _SOC_ observers should get notified of the
           NRF_EVT_HFCLKSTARTED event after this call. */
        err_code = sd_clock_hfclk_request();
        APP_ERROR_CHECK(err_code);

Reply
  • Hi,

    Please verify that the 'nrf_sdh_soc.c' is included in your build. This file implements the STACK OBSERVER responsible for forwarding system events to the NRF_SDH_SOC_OBSERVERs. Also, if you can add the code line below after enabling the Softdevice to ensure there is at least one SoC event source.

        /* Request Softdevice to turn on Crystal oscillator to test if SoC events are
           forwarded to the application. _SOC_ observers should get notified of the
           NRF_EVT_HFCLKSTARTED event after this call. */
        err_code = sd_clock_hfclk_request();
        APP_ERROR_CHECK(err_code);

Children
  • Hi, 

    Thank you for responding. 

    Yes, the file is included. When  I add the code above, the handler does execute. 

    However, no other events trigger the handler, only the line that you included above forces it to execute.

    When I send an ACK that forces an event change, the handler does not run.

  • Thanks for confirming. So it seems to me like the system event forwarding is working as expected since you are getting the NRF_EVT_HFCLKSTARTED event. Are you sure the ACK is supposed to trigger a system event in your application? As you may know, SoC observers will only receive events that are members of the NRF_SOC_EVTS enum.

    The SoftDevice Handler library documentation describes the event forwarding mechanism in more detail.

  • Hi Vidar,

    When I send a specific ACK, in the program it runs a handler that erases the flash. When the flash begins to erase, I expect the handler to get triggered. The handler checks ti see if the flash operation is complete before continuing. 

    In other words, a flash erase is not triggering the  handler. NRF_EVT_FLASH_OPERATION_SUCCESS  is part of the NRF_SOC_EVTS enum. Once the erase is initialize/completed, I expected the system to forward the event, but it is not happening.

    Specifically, I'm sending this:

    ulErrorCode = sd_flash_page_erase(FLASH_LAST_PAGE); 

    and the handler is not working. Is it supposed to forward if i call sd_flash_page_erase?

    Thank you

  • Yes, as long as the Softdevice is enabled and sd_flash_page_erase() returns NRF_SUCCESS, you should always receive a system event. 

    The handler checks ti see if the flash operation is complete before continuing. 

    Is it possible that this check could become blocking? Eg., if it makes the program wait for the System event from another interrupt context of the same or equal priority as the Softdevice interrupt itself (pri=6) and thus prevent the Softdevice interrupt from coming through? 

Related