Could not allocate an interrupt for UART when 4 gptimers interrupts are enabled

ves011
Posts: 20
Joined: Fri Oct 07, 2022 2:31 pm

Could not allocate an interrupt for UART when 4 gptimers interrupts are enabled

Postby ves011 » Tue Mar 26, 2024 9:20 am

I have an application where i need to use the 4 gptimers.
For all of the timers i have an alarm interrupt enabled declared this way

Code: Select all

static bool IRAM_ATTR x_timer_callback(gptimer_handle_t timer, const gptimer_alarm_event_data_t *edata, void *args)
	{
...
    return high_task_awoken == pdTRUE;
	}
	


if all 4 interrupts are installed using

Code: Select all

gptimer_event_callbacks_t cbs = {.on_alarm = &x_timer_callback,};
ESP_ERROR_CHECK(gptimer_register_event_callbacks(x_timer, &cbs, NULL));

I hit this error when console is initialized
E (11:53:42.405) uart: uart_driver_install(1614): Could not allocate an interrupt for UART
If i comment out the call of gptimer_register_callbacks() the uart is working.

Is there any coflict or limitation which prevents using uart console and 4 gptimers at the same time?
My environment is using ESP32 - WROOM32 dev board and esp-idf 5.1.2

MicroController
Posts: 1736
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Could not allocate an interrupt for UART when 4 gptimers interrupts are enabled

Postby MicroController » Tue Mar 26, 2024 12:48 pm

1) You may want to consider using the IDF's "High Resolution Timers" to save on hardware timers.
2) Each CPU core has only a limited number of interrupt vectors. You may have exhausted one core's number of interrupts. Try initializing the UART driver (or the timer) on the other core, e.g. by forcing ("pinning") the task doing the initialization to that core.

ves011
Posts: 20
Joined: Fri Oct 07, 2022 2:31 pm

Re: Could not allocate an interrupt for UART when 4 gptimers interrupts are enabled

Postby ves011 » Tue Mar 26, 2024 3:26 pm

This is what i did. I replaced one of gptimers with an esp_timer.
Looking on Lx6 brief about the interrupts, it says "support for up to 32 interrupts" and its configurable.
Do you have any info about xtensa configuration flavour in esp32 different chips?

Not sure if pinning could help. I can pin a task to a core but how to "pin" an interrupt to a core?
Anyway its too late, i already modified the code :)

MicroController
Posts: 1736
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Could not allocate an interrupt for UART when 4 gptimers interrupts are enabled

Postby MicroController » Tue Mar 26, 2024 9:40 pm

ves011 wrote:
Tue Mar 26, 2024 3:26 pm
Looking on Lx6 brief about the interrupts, it says "support for up to 32 interrupts" and its configurable.
Section 2.3.2 of the ESP32 TRM v4.7:
Both of the two CPUs (PRO and APP) have 32 interrupts each, of which 26 are peripheral interrupts.
But that doesn't mean your application has 32 (or 26) interrupt vectors available for its own use ;-) FreeRTOS, IDF, WiFi and/or other stuff occupy a bunch of interrupts right from the start.
Not sure if pinning could help.
It does.

Who is online

Users browsing this forum: No registered users and 76 guests