# CallBack function is not calling after Timer create and start Successfully

**URL:** <https://forums.freertos.org/t/callback-function-is-not-calling-after-timer-create-and-start-successfully/15015>\
**Category:** Kernel\
**Created:** [May 8, 2022, 9:21am UTC](https://forums.freertos.org/t/callback-function-is-not-calling-after-timer-create-and-start-successfully/15015 "2022-05-08T09:21:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Viswanatha](https://avatars.discourse-cdn.com/v4/letter/v/d26b3c/32.png) [@Viswanatha](https://forums.freertos.org/u/Viswanatha)\
**Post date:** [May 8, 2022, 9:21am UTC](https://forums.freertos.org/t/callback-function-is-not-calling-after-timer-create-and-start-successfully/15015/1 "2022-05-08T09:21:15Z")

</div>

![image](https://d2v6vdsk2p900z.cloudfront.net/original/2X/3/38a3a73ff54521605c20af1007c1834bbd39c885.png)

Could you please help on this.

Using:  
STM32CubeIDE  
Platform MCU

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [May 8, 2022, 5:34pm UTC](https://forums.freertos.org/t/callback-function-is-not-calling-after-timer-create-and-start-successfully/15015/2 "2022-05-08T17:34:23Z")

</div>

Try the same using the native API, and if it doesn’t work, post the code here so I can try it.

---

<div class="post-metadata">

**Author:** ![Viswanatha](https://avatars.discourse-cdn.com/v4/letter/v/d26b3c/32.png) [@Viswanatha](https://forums.freertos.org/u/Viswanatha)\
**Post date:** [May 9, 2022, 1:06am UTC](https://forums.freertos.org/t/callback-function-is-not-calling-after-timer-create-and-start-successfully/15015/3 "2022-05-09T01:06:25Z")

</div>

Hi, this below code not working.  
Could you try from your end please.

```auto
void oneShotCallback( TimerHandle_t pxTimer )
{

}

int main(void)
{
#if 1 

  TimerHandle_t onShotTimer = NULL;
  onShotTimer = xTimerCreate( "oneShotTimer", (5000 / portTICK_PERIOD_MS), pdFALSE, 0, oneShotCallback );

  if( onShotTimer == NULL )
  {
	  // The timer was not created.
  }
  else 
  {
     if( xTimerStart( onShotTimer, 0 ) != pdPASS )
	  {
		  // The timer could not be set into the Active state.
	  }
  }
  
#endif 

  /* Init scheduler */
  osKernelInitialize();
  osKernelStart();

  while (1)
  {
  }
  /* USER CODE END 3 */
}

```

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [May 9, 2022, 1:34am UTC](https://forums.freertos.org/t/callback-function-is-not-calling-after-timer-create-and-start-successfully/15015/4 "2022-05-09T01:34:25Z")

</div>

I just tried the following code, which printed out “5000” as expected:

```auto
void oneShotCallback( TimerHandle_t pxTimer )
{
    printf( "%d", ( int ) xTaskGetTickCount() );
}

int notmain( void )
{
#if 1

    TimerHandle_t onShotTimer = NULL;
    onShotTimer = xTimerCreate( "oneShotTimer", ( 5000 / portTICK_PERIOD_MS ), pdFALSE, 0, oneShotCallback );

    if( onShotTimer == NULL )
    {
        for( ;; );
    }
    else
    {
        if( xTimerStart( onShotTimer, 0 ) != pdPASS )
        {
            for( ;; );
        }
    }

#endif

    /* Init scheduler */
    //osKernelInitialize();
    //osKernelStart();
    vTaskStartScheduler();

    while( 1 )
    {
    }
    /* USER CODE END 3 */
}

```

Can you check the tick interrupt is executing properly - if it isn’t then the system time will be frozen and so the 5 second timer will never expire. The simplest way of doing that is to let the application run for a bit, then inspect the xTickCount variable in the debugger.
