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

Bug: App Scheduler and freeRTOS

There seems to be a bit over a bug with the freeRTOS example. If you add the Scheduler to the BLE thread, Scheduler events will always be one event behind as there are only executed on the next loop. The fix is adding your power_manage() function both before and after the intern_softdevice_events_execute(); in the BLE task.

Parents
  • Hi,

    If you are pulling SoftDevice events in the scheduler you will see this bug. We are fixing this in the upcoming SDK version 14.1. The solution in SDK 14 is to switch the sequence in the softdevice_task() in nrf_sdh_freertos.c

    static void softdevice_task(void * pvParameter)\{
    
        NRF_LOG_DEBUG("Enter softdevice_task.");
    
        if (m_task_hook != NULL) \{
    
            m_task_hook(pvParameter);
    
        }
    
        while (true) \{
    
            nrf_sdh_evts_poll();
    
            (void) ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
    
        }
    
    }
    
  • I added app_sched_execute(); (as well as #include "app_scheduler.h") to port_cmsis_systick.c after the sd_app_evt_wait(); call. This seemed to resolve the issue of delayed events. The main issue was that ONLY ble events were triggering the Scheduler to handle events. So if I posted any application events to the scheduler they simply would not execute until the next BLE event.

Reply
  • I added app_sched_execute(); (as well as #include "app_scheduler.h") to port_cmsis_systick.c after the sd_app_evt_wait(); call. This seemed to resolve the issue of delayed events. The main issue was that ONLY ble events were triggering the Scheduler to handle events. So if I posted any application events to the scheduler they simply would not execute until the next BLE event.

Children
No Data
Related