CallBack function is not calling after Timer create and start Successfully

Could you please help on this.

Using:
STM32CubeIDE
Platform MCU

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

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

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 */
}

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

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.