# Tickless problem

**URL:** <https://forums.freertos.org/t/tickless-problem/21283>\
**Category:** Kernel\
**Created:** [August 29, 2024, 9:45am UTC](https://forums.freertos.org/t/tickless-problem/21283 "2024-08-29T09:45:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tonbaebae](https://avatars.discourse-cdn.com/v4/letter/t/a9adbd/32.png) [@tonbaebae](https://forums.freertos.org/u/tonbaebae)\
**Post date:** [August 29, 2024, 9:45am UTC](https://forums.freertos.org/t/tickless-problem/21283/1 "2024-08-29T09:45:05Z")

</div>

HI ,everyone  
I am trying to use Tickless mode. I have set `#define configUSE_TICKLESS_IDLE 1` and ensured that no other interrupts are enabled. However, the `ulExpectedIdleTime` that I print out is always 3.(but my task has 1000ms delay time)  
I’m not sure what else needs to be adjusted. Could someone please help?

```c
void StartDefaultTask(void *argument)
{
  /* USER CODE BEGIN 5 */
  /* Infinite loop */
  for(;;)
  {
	  time_log();
	  printf("StartTask01\n");
	  osDelay(1000);
  }
  /* USER CODE END 5 */
}

__weak void PreSleepProcessing(uint32_t ulExpectedIdleTime)

{

/* place for user code */

printf("ulExpectedIdleTime:%ld\n");

}

```

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [August 29, 2024, 4:22pm UTC](https://forums.freertos.org/t/tickless-problem/21283/2 "2024-08-29T16:22:32Z")

</div>

> [@tonbaebae](#):
>
> `osDelay(1000);`

Can you replace this with `vTaskDelay( pdMS_TO_TICKS( 1000 ) );`? Which hardware and which FreeRTOS version are you using?

---

<div class="post-metadata">

**Author:** ![tonbaebae](https://avatars.discourse-cdn.com/v4/letter/t/a9adbd/32.png) [@tonbaebae](https://forums.freertos.org/u/tonbaebae)\
**Post date:** [August 30, 2024, 7:24am UTC](https://forums.freertos.org/t/tickless-problem/21283/3 "2024-08-30T07:24:14Z")

</div>

thanks,  
but I have already tried replacing `osDelay` with `vTaskDelay`, but the value is still 3.  
my rtos version is “V10.3.1” and MCU is STM32L562

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [August 30, 2024, 8:58am UTC](https://forums.freertos.org/t/tickless-problem/21283/4 "2024-08-30T08:58:37Z")

</div>

Is there any other task in your system? Can you share the complete code?

---

<div class="post-metadata">

**Author:** ![tonbaebae](https://avatars.discourse-cdn.com/v4/letter/t/a9adbd/32.png) [@tonbaebae](https://forums.freertos.org/u/tonbaebae)\
**Post date:** [August 30, 2024, 9:13am UTC](https://forums.freertos.org/t/tickless-problem/21283/5 "2024-08-30T09:13:34Z")

</div>

Here is my code. Besides setting `#define configUSE_TICKLESS_IDLE 1` and creating a task, I haven’t done anything else.

```c
static void MX_GPIO_Init(void)
{
/* USER CODE BEGIN MX_GPIO_Init_1 */
/* USER CODE END MX_GPIO_Init_1 */

  /* GPIO Ports Clock Enable */
  __HAL_RCC_GPIOA_CLK_ENABLE();
  __HAL_RCC_GPIOG_CLK_ENABLE();
  HAL_PWREx_EnableVddIO2();

/* USER CODE BEGIN MX_GPIO_Init_2 */
/* USER CODE END MX_GPIO_Init_2 */
}

int main(void)
{
  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  /* USER CODE BEGIN 2 */

  /* USER CODE END 2 */

  /* Init scheduler */
  osKernelInitialize();

  /* USER CODE BEGIN RTOS_MUTEX */
  /* add mutexes, ... */
  /* USER CODE END RTOS_MUTEX */

  /* USER CODE BEGIN RTOS_SEMAPHORES */
  /* add semaphores, ... */
  /* USER CODE END RTOS_SEMAPHORES */

  /* USER CODE BEGIN RTOS_TIMERS */
  /* start timers, add new ones, ... */
  /* USER CODE END RTOS_TIMERS */

  /* USER CODE BEGIN RTOS_QUEUES */
  /* add queues, ... */
  /* USER CODE END RTOS_QUEUES */

  /* Create the thread(s) */
  /* creation of defaultTask */
  defaultTaskHandle = osThreadNew(StartDefaultTask, NULL, &defaultTask_attributes);

  /* USER CODE BEGIN RTOS_THREADS */
  /* add threads, ... */
  /* USER CODE END RTOS_THREADS */

  /* USER CODE BEGIN RTOS_EVENTS */
  /* add events, ... */
  /* USER CODE END RTOS_EVENTS */

  /* Start scheduler */
  osKernelStart();

  /* We should never get here as control is now taken by the scheduler */
  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}

void StartDefaultTask(void *argument)
{
  /* USER CODE BEGIN 5 */
  /* Infinite loop */
  for(;;)
  {
	  printf("StartTask01\n");
	  osDelay(1000);
// vTaskDelay( pdMS_TO_TICKS( 1000 ) );
  }
  /* USER CODE END 5 */
}

__weak void PreSleepProcessing(uint32_t ulExpectedIdleTime)
{
/* place for user code */
	printf("ulExpectedIdleTime:[%d]\n", ulExpectedIdleTime);
}

```

Thanks.

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [August 30, 2024, 10:36am UTC](https://forums.freertos.org/t/tickless-problem/21283/6 "2024-08-30T10:36:16Z")

</div>

When I say complete code, I mean the complete project that I can build and try. Either you can zip it up and attach or put in a GitHub repo and share the link.
