2021-08-02 10:48 AM
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
Solved! Go to Solution.
2021-08-02 12:23 PM
In GPIO, go to the NVIC tab and enable the interrupts.
Also, defining user labels with a "#" in the name is no recommended. Might work, might not.
2021-08-02 11:23 AM
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.
2021-08-02 11:55 AM
2021-08-02 12:02 PM
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.
2021-08-02 12:13 PM
2021-08-02 12:23 PM
In GPIO, go to the NVIC tab and enable the interrupts.
Also, defining user labels with a "#" in the name is no recommended. Might work, might not.
2021-08-02 12:40 PM
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
2021-08-03 11:02 AM
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.