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

Task Not Switching in FreeRTOS example in Nordic SDK

Hi All,

Am using NRF52, SDK 11.0.0.2 alpha , I am using HRS free RTOS example. In that I just created two tasks of equal priority. As per Free RTOS two task must switch without giving any task delay. But In my case Task is not switching .

Task Creation:

// Start execution.
    if(pdPASS != xTaskCreate(ble_stack_thread, "BLE", 128, NULL, 2, &m_ble_stack_thread))
    {
        APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
    }
    if(pdPASS != xTaskCreate(user_thread, "USER", 128, NULL, 2, &m_user_thread))
    {
        APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
    }
    /* Activate deep sleep mode */
    SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;

    // Start FreeRTOS scheduler.
    vTaskStartScheduler();

Tasks:-

static void user_thread(void *arg)
{
	while(1){
		printf("test\r\n");
		
	}
}

static void ble_stack_thread(void * arg)
{
	while(1){
		printf("BLE\r\n");
	}
}

I also changed the config

#define configUSE_TIME_SLICING                                                    1
#define configUSE_PREEMPTION                                                      1
Parents
  • You need to start the LFCLK before creating the threads. For example with:

    NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
    NRF_CLOCK->TASKS_LFCLKSTART = 1;
    
    while(NRF_CLOCK->EVENTS_LFCLKSTARTED == 0);
    

    Take a look at the blinky_FreeRTOS example in the SDK (this uses the clock driver instead).

Reply
  • You need to start the LFCLK before creating the threads. For example with:

    NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
    NRF_CLOCK->TASKS_LFCLKSTART = 1;
    
    while(NRF_CLOCK->EVENTS_LFCLKSTARTED == 0);
    

    Take a look at the blinky_FreeRTOS example in the SDK (this uses the clock driver instead).

Children
Related