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: 305
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: 481
Joined: Sun Mar 31, 2019 5:16 am
Location: Brazil

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

danmcb
Posts: 2
Joined: Fri Sep 13, 2024 8:08 am

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

Postby danmcb » Wed Jan 29, 2025 3:47 pm

I see this same issue exactly, with IDF 5.3

I just ignore the errors, the junk on the terminal is annoying but the hardware works fine.

It really seems like a bug, the timer IS for sure getting enabled before I try to start it.

Any fix for the spurious error?

(EDIT - the issue seems to be fixed in 5.4)

Baldhead
Posts: 481
Joined: Sun Mar 31, 2019 5:16 am
Location: Brazil

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

Postby Baldhead » Sun Feb 09, 2025 1:43 am

danmcb wrote:
Wed Jan 29, 2025 3:47 pm
I see this same issue exactly, with IDF 5.3

I just ignore the errors, the junk on the terminal is annoying but the hardware works fine.

It really seems like a bug, the timer IS for sure getting enabled before I try to start it.

Any fix for the spurious error?

(EDIT - the issue seems to be fixed in 5.4)
I also noticed that they changed this part of the code in esp-idf v5.4, now whether it was resolved I don't know.

I also ended up not using GPTIMER and chose to use MCPWM, which initially worked well in my application.

Who is online

Users browsing this forum: No registered users and 89 guests