GPTimer not enabled yet error, but timer works as intended

Raphelchen
Posts: 1
Joined: Thu Jul 20, 2023 9:32 am

GPTimer not enabled yet error, but timer works as intended

Postby Raphelchen » Thu Jul 20, 2023 9:49 am

Hi,
i have two timers for a esp32-s3 on esp-idf 5.0.2
I init the timers with:

Code: Select all

gptimer_config_t timer_config = {
    .clk_src = GPTIMER_CLK_SRC_DEFAULT,
    .direction = GPTIMER_COUNT_UP,
    .resolution_hz = 1000000, // 1us
  };
  
  //Setup Callback
  gptimer_event_callbacks_t cbs = {
    .on_alarm = timer_interrupt_handler,
  };

  ESP_ERROR_CHECK(gptimer_new_timer(&timer_config, &timer_1));
  ESP_ERROR_CHECK(gptimer_register_event_callbacks(timer_1, &cbs, (void*)8));
  ESP_ERROR_CHECK(gptimer_enable(timer_1));

  ESP_ERROR_CHECK(gptimer_new_timer(&timer_config, &timer_2));
  ESP_ERROR_CHECK(gptimer_register_event_callbacks(timer_2, &cbs, (void*)9));
  ESP_ERROR_CHECK(gptimer_enable(timer_2));

  //Setup Alarms
  timer_1_alarm_config ={
    .alarm_count = 10000,
    .reload_count = 0,
  };
  timer_1_alarm_config.flags.auto_reload_on_alarm = false;
  timer_2_alarm_config ={
    .alarm_count = 450000,
    .reload_count = 0,
  };
  timer_2_alarm_config.flags.auto_reload_on_alarm = false;
  ESP_ERROR_CHECK(gptimer_set_alarm_action(timer_1, &timer_1_alarm_config));
  ESP_ERROR_CHECK(gptimer_set_alarm_action(timer_2, &timer_2_alarm_config));
Both timers work as intended, but timer_1spits out this error over uart
E (4167944) gptimer: gptimer_start(370): timer is not enabled yet

I'm not sure what the problem is.
I tried initialising them the other way round. No change.
I tried initialising them at different points in the code. No change.

User avatar
mbratch
Posts: 303
Joined: Fri Jun 11, 2021 1:51 pm

Re: GPTimer not enabled yet error, but timer works as intended

Postby mbratch » Fri Jun 14, 2024 1:28 pm

I know this post is already several months old but...

I get this same error if, for example, I do a UART transmission after I start the timer. If I disable my UART transmissions, I do not get the gptimer error.

What else is your code doing while the timer is running?

Baldhead
Posts: 468
Joined: Sun Mar 31, 2019 5:16 am

Re: GPTimer not enabled yet error, but timer works as intended

Postby Baldhead » Wed Oct 23, 2024 7:30 pm

Raphelchen wrote:
Thu Jul 20, 2023 9:49 am
Hi,
i have two timers for a esp32-s3 on esp-idf 5.0.2
I init the timers with:

Code: Select all

gptimer_config_t timer_config = {
    .clk_src = GPTIMER_CLK_SRC_DEFAULT,
    .direction = GPTIMER_COUNT_UP,
    .resolution_hz = 1000000, // 1us
  };
  
  //Setup Callback
  gptimer_event_callbacks_t cbs = {
    .on_alarm = timer_interrupt_handler,
  };

  ESP_ERROR_CHECK(gptimer_new_timer(&timer_config, &timer_1));
  ESP_ERROR_CHECK(gptimer_register_event_callbacks(timer_1, &cbs, (void*)8));
  ESP_ERROR_CHECK(gptimer_enable(timer_1));

  ESP_ERROR_CHECK(gptimer_new_timer(&timer_config, &timer_2));
  ESP_ERROR_CHECK(gptimer_register_event_callbacks(timer_2, &cbs, (void*)9));
  ESP_ERROR_CHECK(gptimer_enable(timer_2));

  //Setup Alarms
  timer_1_alarm_config ={
    .alarm_count = 10000,
    .reload_count = 0,
  };
  timer_1_alarm_config.flags.auto_reload_on_alarm = false;
  timer_2_alarm_config ={
    .alarm_count = 450000,
    .reload_count = 0,
  };
  timer_2_alarm_config.flags.auto_reload_on_alarm = false;
  ESP_ERROR_CHECK(gptimer_set_alarm_action(timer_1, &timer_1_alarm_config));
  ESP_ERROR_CHECK(gptimer_set_alarm_action(timer_2, &timer_2_alarm_config));
Both timers work as intended, but timer_1spits out this error over uart
E (4167944) gptimer: gptimer_start(370): timer is not enabled yet

I'm not sure what the problem is.
I tried initialising them the other way round. No change.
I tried initialising them at different points in the code. No change.
Same problem here.

The timer works as expected, but show this message:
E (679) gptimer: gptimer_start(399): timer is not enabled yet

Notes:
ESP32-S3
ESP-IDF v5.3.1

Who is online

Users browsing this forum: Baidu [Spider], Majestic-12 [Bot] and 347 guests