2023-01-23 06:35 AM
Hi,
After reading the document I understand the interrupts are handled by pin#, and we set GPIOsel within EXTI_ConfigTypeDef.
My question is how do we determine which port generates the interrupt?
Suppose I use PA0 and PB0, and I only want to use one callback function for them.
void callback()
{
if(port == GPIOA)
{
do something
}
else if(port == GPIOB)
{
do other thing
}
}
Thank you
Solved! Go to Solution.
2023-01-23 07:28 AM
Hi, unfortunately, EXTI cannot be programmed for PA0 and PB0 (you should have seen this restriction when you started your design with CubeMX).
Some possible solutions (just for your information, not tested):
Regards.
2023-01-23 06:38 AM
I know one way is to set EXTI_ConfigTypeDef exti_config as a global variable, and pass it into the callback function. Is there another way to do it?
2023-01-23 06:54 AM
Hi,
your example wont fly as you cannot have at same time EXTI0 set for PA0 and PB0.
If you MUXSEL is not static (i.e. dynamic SW changes from PA0 to PB0 and vice-versa), in the interrupt routine, you could check the content of EXTI_EXTICR1.EXTI0 (example for EXTI0) to know if interrupt was set to PA0, PB0, PC0, etc. This could save you some global variable.
Regards.
2023-01-23 07:01 AM
Thanks Patrick,
If I want PA0 and PB0 both can generate interrupt, is there a way to do it?
2023-01-23 07:02 AM
These two interrupts won't be triggered at same time.
2023-01-23 07:03 AM
@PatrickF
2023-01-23 07:28 AM
Hi, unfortunately, EXTI cannot be programmed for PA0 and PB0 (you should have seen this restriction when you started your design with CubeMX).
Some possible solutions (just for your information, not tested):
Regards.
2023-01-23 07:30 AM
Thank you for the clarification Patrick
2023-08-02 07:22 AM
Hi @PatrickF,
your answer has been super useful to me too! Many thanks!!!
In the datasheet is not reported that "only one line" can work at the time. From the picture looks like that the EXTIx is shared across all these inputs (PA0, PB0, PC0, ...).
I also found some misleading webpages on this topic, so an official document would be definitely help!
Kind regards,
AGA