cancel
Showing results for 
Search instead for 
Did you mean: 

How to enable GPIO EXTIx interrupts?

Louie88
Associate III

Hi,

I need to enable interrupts for pins PJ0, PJ3, PJ4 and PJ5. Why these pins? Because they are connected to the ARDUINO connector (CN5 and CN6) of the STM32H7474I-DISCO board and they all seem to be all free. I have the initialization code (Hopefully right) but I have no glue how enable and handle the interrupts. Can anybody help?

GPIO_InitTypeDef GPIO_InitStruct = {0};
__HAL_RCC_GPIOJ_CLK_ENABLE();
/*Configure GPIO pins : PJ0 PJ5 PJ3 PJ4 */
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_5|GPIO_PIN_3|GPIO_PIN_4;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOJ, &GPIO_InitStruct);

Thanks,

Louis

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

In GPIO, go to the NVIC tab and enable the interrupts.

0693W00000D1KMGQA3.png 

Also, defining user labels with a "#" in the name is no recommended. Might work, might not.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

7 REPLIES 7
TDK
Guru

You need to enable the interrupt with HAL_NVIC_EnableIRQ or NVIC_EnableIRQ and set up the appropriate port settings within EXTI using HAL_EXTI_SetConfigLine or by manually accessing registers.

After that, to handle the interrupt, you need to add the appropriately named handler for the ports you're using which are listed in the vector table within the startup_*.s file.

If you generate code with CubeMX, it will add these for you.

If you feel a post has answered your question, please click "Accept as Solution".
Louie88
Associate III

Thanks TDK!

I generated the app with CubeMX but it did not generate the interrupt setup and handlers. Here is the screenshot of CubeMX:

0693W00000D1KFtQAN.pngThanks again,

Louis

Are you sure? Where are you looking? Interrupts handlers are in *_it.c by default.

Post your IOC file if you can, or make a new one that exhibits the same behavior and post that.

If you feel a post has answered your question, please click "Accept as Solution".

Thanks for the very quick answer, TDK!!!

Well, the whole STM32H7xxx is too foggy to me to be sure, However in the*_it.c I found these functions only:

0693W00000D1KJMQA3.pngI attached the *.ioc file.

Thanks for helping me...

Louis

TDK
Guru

In GPIO, go to the NVIC tab and enable the interrupts.

0693W00000D1KMGQA3.png 

Also, defining user labels with a "#" in the name is no recommended. Might work, might not.

If you feel a post has answered your question, please click "Accept as Solution".
Louie88
Associate III

Obvious, thanks! I will try that tomorrow morning.

I am very new with CubeMX, but anyway, it is a very nice tool (if you can use it)

Sorry for the stupid question.

Louis

Hi TDK!

Thank you very much, it is working just fine. Thanks for your help. I appreciate it very much!

Best regards,

Louis

PS: I have a topic (more than one) in STemWin forum, but nobody answers my questions (nor the tech support). It seems to me nobody check that forum. Maybe you can advice me about this topic: How to add STemWin library to a new project? It might be CubeMX related.