2025-08-05 1:29 PM
I am experimenting with a STM32G431 dev board (breadboard friendly) but eventually the project will use a STM32H723 mcu.
I am generating PWM and PWMN signals with dead time using timer 15. I need to generate additional signals based on these two and I would like to configure interrupts on the PWM and PWMN rising and falling edges. I could short the PWM and PWMN pins to adjacent pins and configure those as EXTI inputs. However, in a reply to another thread user @TDK said it is possible to configure a pin as both PWM and EXTI input and thus generate interrupts directly from the PWM signal. This seems like a much better solution but unfortunately I haven't been able to figure out how to do it. In STM32CubeMX if I configure a pin for PWM, then try to configure the same pin as EXTI, the PWM is disabled and the pin is configured just for EXTI. And vice-versa.
Is it possible to do what I want? If so, how should I go about it?
Thanks
paul
Solved! Go to Solution.
2025-08-05 2:02 PM
You can't do it in CubeMX, but the hardware supports it.
After configuring the pin for the timer, configure the EXTI registers to have an interrupt on that pin during rising and falling edges. SYSCFG->EXTICR, EXTI->RTSRx, EXTI->FTSRx registers. You'll also need to enable and implement the appropriate EXTI interrupt.
You might be able to do it with HAL if you pass GPIO_MODE_AF_PP | GPIO_MODE_IT_RISING_FALLING as the pin mode to HAL_GPIO_Init. I did not test this, but looks like it should work. Still need to enable the interrupt yourself.
2025-08-05 2:02 PM
You can't do it in CubeMX, but the hardware supports it.
After configuring the pin for the timer, configure the EXTI registers to have an interrupt on that pin during rising and falling edges. SYSCFG->EXTICR, EXTI->RTSRx, EXTI->FTSRx registers. You'll also need to enable and implement the appropriate EXTI interrupt.
You might be able to do it with HAL if you pass GPIO_MODE_AF_PP | GPIO_MODE_IT_RISING_FALLING as the pin mode to HAL_GPIO_Init. I did not test this, but looks like it should work. Still need to enable the interrupt yourself.
2025-08-05 2:56 PM
Fantastic thanks for the quick reply. I'll give that a go.
Thanks
paul
2025-08-05 3:29 PM
TIM should allow you to pair CH1/CH2 or CH3/CH4, such that you can Input Capture on opposite edges of related pin, and generate a CCx for the CCR the CNT gets latched into.
Input Capture PWM can be similarly arranged, and also reset CNT such that one channel gets duty and the other period.