8 years, 6 months ago.

STM32 nucleo EXTI interrupt, after signal nucleo stop

with this easy code i make signal to PA0 to enable EXTI interrupt and set count1 to 0

after interrupt nucleo stop loop cycle !

where is my error?

link https://developer.mbed.org/users/c128/code/interrupt_test_stm32_nucle/

https://developer.mbed.org/users/c128/code/interrupt_test_stm32_nucle/file/c5e2a50f0d5d/main.cpp

include the mbed library with this snippet

#include "mbed.h"
#include "stm32f4xx.h"
#include "stm32f4xx_hal_tim_ex.h"
#include "stm32f4xx_hal_conf.h"
 
 
 
int16_t count1 = 10; 
 
 
void EXTI0_IRQHandler(void)
{
    HAL_NVIC_ClearPendingIRQ(EXTI0_IRQn);
    HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0);
}
 
void HAL_GPIO_EXTI_Callback (uint16_t GPIO_Pin)
{
    if (GPIO_Pin == GPIO_PIN_0) {
        count1 = 0;
    }
}
 
int main()
{
    HAL_Init();
 
    GPIO_InitTypeDef GPIO_InitStruct;
    __GPIOA_CLK_ENABLE();
    GPIO_InitStruct.Pin = GPIO_PIN_0;  //PA0 as interrupt test
    GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
    GPIO_InitStruct.Pull = GPIO_PULLDOWN;
    GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
    HAL_NVIC_SetPriority(EXTI0_IRQn, 0, 1);
    HAL_NVIC_EnableIRQ(EXTI0_IRQn);
 
 
    while (1) {
 
        printf("loop%d\r\n", count1);
        wait(1);
 
 
    }
 
}


3 Answers

6 years, 7 months ago.

I have completely THE SAME PROBLEM with my NUCLEO-F767ZI board. I hope somebody will answer here.

Regards, Ales Zupanc

Did you get your code working?

posted by Ales Zupanc 04 Sep 2017
6 years, 7 months ago.

This is not mbed code, just pure STM32 HAL. Check mbed's interrupt in API here: https://docs.mbed.com/docs/mbed-os-api-reference/en/latest/APIs/io/InterruptIn/

You shall declare count1 volatile.

posted by Mark Peter Vargha 08 Sep 2017
6 years, 7 months ago.

Hi

If you want to use pure STM32 HAL in mbed, please see GPIO EXTI example available in STM32CubeF7 package.

http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-embedded-software/stm32cubef7.html

BTW why don't you use mbed api for this ?