2025-07-12 5:13 AM
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);
}
					
				
			
			
				
			
			
				
			
			
			
			
			
			
		2025-07-12 5:15 AM - edited 2025-07-12 5:18 AM
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