Skip to main content
Visitor II
July 12, 2025
Question

FreeRTOS Timer Callback is not firing [CMSIS_RTOS_V2]

  • July 12, 2025
  • 1 reply
  • 257 views
osTimerId_t FreertosTimerHandle;

const osTimerAttr_t FreertosTimer_attr =
{
 .name = "FreertosTimer_LED"
};

void RPS_print_console_Thread(void *argument)
{
	/* Initialize watchdog Timer */
	IWDG_Init();
	StartLEDTimer();
	while(1)
	{
		/* Refresh watchdog periodically */
		IWDG_Refresh();
	}
}

void StartLEDTimer(void)
{
 FreertosTimerHandle = osTimerNew(Fire_LED_Toggle, osTimerOnce, NULL, &FreertosTimer_attr);

 if (FreertosTimerHandle != NULL)
 {
 if (osTimerStart(FreertosTimerHandle, 5000) == osOK)
 {
 printf("LED timer started\n");
 }
 else
 {
 printf("Failed to start LED timer\n");
 }
 }
 else
 {
 printf("Failed to create LED timer\n");
 }
}

void Fire_LED_Toggle(void *argument)
{
	printf("Timer callback fired!\n");

	HAL_GPIO_WritePin(LED0_GPIO_Port, LED0_Pin, SET);
	HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, SET);
	HAL_GPIO_WritePin(LED2_GPIO_Port, LED2_Pin, SET);
	HAL_GPIO_WritePin(LED3_GPIO_Port, LED3_Pin, SET);
}
    This topic has been closed for replies.

    1 reply

    ram_janAuthor
    Visitor II
    July 12, 2025

    Hi Team, 

    Currently I am working with FreeRTOS Timers and callback is not firing always.

    Please note that timer is created and osKernelInitialize(); called before the user code and these are configurations in FreeRTOSConfig.h.

     

    /* Software timer definitions. */

    #define configUSE_TIMERS 1

    #define configTIMER_TASK_PRIORITY ( 6 )

    #define configTIMER_QUEUE_LENGTH 10

    #define configTIMER_TASK_STACK_DEPTH 256