Skip to main content
gil_dobjanschi
Associate II
April 18, 2026
Question

Access function for EXTI handle of a timer

  • April 18, 2026
  • 5 replies
  • 137 views

Hello,

 

I configured TIM5 to generate a signal out to a pin using STM32CubeMX2 for a Nucleo-C562RE board. I enabled the EXTI interrupt for the pin in the timer configuration to get EXTI6 interrupts on the falling edge. I also enabled the use of register callbacks for EXTI.

The problem that I am having is that I cannot find the function to retrieve hEXTI6 to register the EXTI callback. I looked in the mx_tim5.h/c and in mx_gpio_default.h/c. I had no problem getting the EXTI handles for GPIO EXTI (for example mx_gpio_default_exti7_gethandle()) and getting TIM handles (mx_tim5_gethandle()).

 

To make the code work I had to add mx_gpio_default_exti6_gethandle() prototype to mx_tim5.h and the implementation below to mx_tim5.c:

 

hal_exti_handle_t *mx_gpio_default_exti6_gethandle(void)
{
	return (&hEXTI6);
}

 

Maybe the definition/function is there but I cannot find it or maybe there is some additional configuration to be done in STM32CubeMX2. I attached my ioc2 file.

 

Regards,

Gil

5 replies

MM..1
Chief III
April 18, 2026

EXTI is hw based, and your "add func" not add hw. Learn how is NVIC and for example you read in MX NVIC window names of existed IRQs. I dont open this , but STM family have EXTIs for single gpio and shared. How is wired 562 read in docu. (0,1,2,3,4,5-8,9-15 maybe) Primary most func cant share EXTI , then your idea TIM OUT and EXTI IN is impossible on same pin. Too your idea is waste of ... TIM generate own interrupts , then use it directly.

gil_dobjanschi
Associate II
April 18, 2026

In STM32CubeMX2 it is possible to turn on EXTI for the output pin. This could be useful when you want to generate a modulated signal. Set the timer to the modulation frequency (say 20KHz) and use the EXTI to count a certain number of modulation pulses. Then, turn off the output of the timer to the pin, count a certain number of modulation pulses (since the timer is still running) and then turn on the output to the pin again, and so on. This enables the modulated signal start and stop to be synchronized with the rising or falling edge of the modulation clock.

 

 

Technical Moderator
April 21, 2026

Hello @gil_dobjanschi 


@gil_dobjanschi wrote:

I attached my ioc2 file.


There is no attached ioc2 file. Could you please share it?

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question.Saket_Om"
gil_dobjanschi
Associate II
April 21, 2026

Hi @Saket_Om ,

 

Sorry about that! I attached the file.

The EXTI was enabled for TIM5. I searched for EXTI6 in the generated code and I see this comment:

 /* *************************************************************
 TIM5 / EXTI6: No EXTI software label has been defined for this peripheral instance
 in the STM32CubeMX2 configuration panel.
 As a result, no aliases are generated for mx_tim5_exti6_gethandle
 ************************************************************* */

I'm not sure what it means. I did not have to define an alias for other EXTI interrupts I used. Granted, those were not timer EXTI interrupts.

Regards,

-Gil

Technical Moderator
April 22, 2026

Hello @gil_dobjanschi 

Thank you for bringing this issue to our attention.

I reported this internally.

Internal ticket number: CDM0062018 (This is an internal tracking number and is not accessible or usable by customers).

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question.Saket_Om"
April 21, 2026

It looks like you’ve already found a practical workaround by manually exposing the EXTI handle, which is great. In STM32CubeMX, sometimes certain EXTI handles aren’t auto-generated depending on how the peripheral is configured, especially when tied to timers instead of direct GPIO interrupts. You might want to double-check the EXTI line mapping and NVIC settings, as well as ensure the callback registration is properly enabled in the configuration. It could also be a limitation or missed generation in the tool itself. By the way, for quick and simple online tools, you can also check this useful percentage calculator.