xTimerCreateStatic not firing

I’m not sure what I’m doing wrong here, I’m fairly advanced into a working RTOS project when I can’t get xTimerCreateStatic to start.

related configs

#define configUSE_PREEMPTION                    1
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
#define configUSE_QUEUE_SETS                    1
#define configUSE_IDLE_HOOK                     1
#define configUSE_TICK_HOOK                     0
#define configCPU_CLOCK_HZ                      (120000000)
#define configTICK_RATE_HZ                      (1000)
#define configMAX_PRIORITIES                    (10)
#define configMINIMAL_STACK_SIZE                ((unsigned short)130)

/* Software timer definitions. */
#define configUSE_TIMERS              1
#define configTIMER_TASK_PRIORITY     (configMAX_PRIORITIES - 1)
#define configTIMER_QUEUE_LENGTH      5
#define configTIMER_TASK_STACK_DEPTH  (configMINIMAL_STACK_SIZE * 2)

I can confirm that the scheduler is running the timer service, although it gets a xNextExpireTime of 0 when running in static portTASK_FUNCTION( prvTimerTask, pvParameters ) so it basically permanently blocks there. IDLE task is at about 98% CPU, so I don’t really think its a starve problem.

I’m setting it up like this:

#define STACK_SIZE 1024
static TaskHandle_t processHandle;
static StackType_t xStack[STACK_SIZE];
static StaticTask_t xTaskBuffer;
static TimerHandle_t xBlinkTimer;
static StaticTimer_t xBlinkTimerBuffer;

static void mainUITasks(void *params);
static void key_event(uint32_t value);
static void vTimerCallback(TimerHandle_t xTimer);

/* Shared control vars for menu */

void main_UI_Initialize(void) {
  processHandle = xTaskCreateStatic(
      mainUITasks, "Main-UI", STACK_SIZE, NULL, PRIORITY_RTOS_MAIN_UI, xStack, &xTaskBuffer);
  registerTask(&processHandle, STACK_SIZE);
  menuInit();
  registerKeyEventCallback(key_event);
  xBlinkTimer = xTimerCreateStatic("Blink", 200, pdTRUE, (void *)0, vTimerCallback, &xBlinkTimerBuffer);
}

static void vTimerCallback(TimerHandle_t xTimer) {
  (void)xTimer;
  menuRefreshEventProcess(200);
}

Device is a STM32L4R9 running at 120mhz.

I may have simply missed it – but are you calling xTimerStart()?

1 Like

No, I missed it… Thanks.