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

SOFTDEVICE_HANDLER_APPSH_INIT + pstorage

ble_senso4s_v_0_7_poenostavljena4_1 power_manager.rarHi

I read a lot about p_storage library and I tested it and works great if I use SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, NULL). On the other hand, If SOFTDEVICE_HANDLER_APPSH_INIT function is used for starting softdevice then the program stucks in while loop where the power_manage() function is located. I will be appreciated for any kind of information why this event happened and what is the reason for this.

best regards

Mike

  • Hi,

    1. What SDK and softdevice versions are you using?
    2. Do you mind uploading your code? (You can edit your first questions and attach files)
    3. power_manage() is located in the main while forever loop in main() right? What do you mean stuck? The code is supposed to loop forever and wake up on system and BLE events.
  • Hi Martin,

    I think that I found out the problem. I will be really appreciated if you can confirm my assumption. In my code, the times are executed in the main loop because I am using the scheduler. The softdevice is also executed in the main loop which means that BLE event does not have higher priority compared to the application timers (where pstorage_update function and subsequently power_manage() function are called). Both of them are loaded in the queue according to schedule rule. Because BLE event and timers are executed with the same priority, the code waits for a p_storage flag longer than the critical interval for execution of BLE event. Due to this fact, I guess that BLE event cannot be executed just in time. I use SDK 10. If my assumption is not true then I will upload the code.

  • Hi,

    1. What kind of timers are you using? The app_timer library? With scheduler?
    2. Can you confirm that your code is actually looping in this standard power_manage function

    :

    static void power_manage(void)
    {
        uint32_t err_code = sd_app_evt_wait();
        APP_ERROR_CHECK(err_code);
    }
    

    And that no other code is executed? If this is an issue with interrupt priorities and the softdevice it seems strange that you don't get hard faults.

  • Hi Martin,

    I use app_timer library and APP_TIMER_APPSH_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, true) function for the timer scheduler.Tomorrow I will try to do additional experiments and I will reply to your second question as fast as possible

  • I added the program to my first post, in which I implemented a similar situation which happened in my original code. I use one time called m_mass_battery_timer_id and it is executed 2500ms after power on. When the timer is executed four bytes are stored in flash but the program does not pass through the while loop where the power_manage() is located. If I replace power_manage() function with app_sched_execute() then the program works fine. the program is located in the pca 10028 file. I will be very pleased with any feedback.

Related