AnsweredAssumed Answered

stm32f429-disco and interrupt initialization question

Question asked by hwe on Jun 23, 2014
Latest reply on Jun 26, 2014 by Clive One
Dear experts,
as a beginner I am starting on a stm32f429-disco board using eclipse with the gnu-arm-plugin and the gnu-arm-eabi toolchain in linux.
I adopted the example from "STM32Cube_FW_F4_V1.1.0/Projects/STM32F429I-Discovery/Examples/GPIO/GPIO_EXTI" to my toolchain.

I want to get an interrupt when the button is pressed an turn on a LED - but nothing happens when the button is pressed !
In debug mode I found that it never enters the callback-function. I guess there is something missing, but what ?

I saw other examples where the interrupts are initialized with function like
    "SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA, EXTI_PinSource0);          or
.EXTI_Line = EXTI_Line0;"
are used with includes like
   #include "stm32f4xx_gpio.h"
    #include "stm32f4xx_exti.h"

but these functinos are not used in the example NOR these includes are available in my toolchain using STM32Cube_FW_F4_V1.1.0 ?

All includes available includes are called "stm32f4xx_hal_......h" - Why ?

Please help me understanding the issue with the interrupt and the different include files - Thanx!

Below is the code:
// This file is part of the GNU ARM Eclipse distribution.
// Copyright (c) 2014 Liviu Ionescu.
// ----------------------------------------------------------------------------
#include <stdio.h>
#include "diag/Trace.h"
#include "cmsis_device.h"
#include "cortexm/ExceptionHandlers.h"
#include "stm32f4xx.h"
#include "stm32f4xx_hal.h"
// ----- main() ---------------------------------------------------------------
// Sample pragmas to cope with warnings. Please note the related line at
// the end of this function, used to pop the compiler diagnostics status.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#pragma GCC diagnostic ignored "-Wreturn-type"
int main(int argc, char* argv[])
        GPIO_InitTypeDef GPIO_InitStructure;
        // Initialize green LEDs on PG13 and PG14
          // Enable GPIO Peripheral clock on Port G for LEDs
            // Configure pin in output push/pull mode
            GPIO_InitStructure.Pin = GPIO_PIN_13;
            GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
            GPIO_InitStructure.Speed = GPIO_SPEED_FAST;
            GPIO_InitStructure.Pull = GPIO_PULLUP;
            HAL_GPIO_Init(GPIOG, &GPIO_InitStructure);
            // Configure pin in output push/pull mode
            GPIO_InitStructure.Pin = GPIO_PIN_14;
            GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
            GPIO_InitStructure.Speed = GPIO_SPEED_FAST;
            GPIO_InitStructure.Pull = GPIO_PULLUP;
            HAL_GPIO_Init(GPIOG, &GPIO_InitStructure);
        // Initialize Pushbutton on PA0 as interrupt driven
            //Configure Button pin as input on PA0
            GPIO_InitStructure.Pin = GPIO_PIN_0;
            GPIO_InitStructure.Mode = GPIO_MODE_IT_RISING_FALLING;
            //GPIO_InitStructure.Mode = GPIO_MODE_INPUT;
            GPIO_InitStructure.Speed = GPIO_SPEED_FAST;
            GPIO_InitStructure.Pull = GPIO_PULLDOWN;;
            HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
            /* Enable and set EXTI Line0 Interrupt to the lowest priority */
            HAL_NVIC_SetPriority(EXTI0_IRQn, 2, 0);
    /*** While loop ***
    //initialize LED state
    HAL_GPIO_WritePin(GPIOG,GPIO_PIN_13, GPIO_PIN_RESET);   // green OFF
          // Infinite loop
          while (1)
          // Infinite loop, never return.
// ----- External Interrupt () ------------------------------------------------
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
      if(GPIO_Pin == GPIO_PIN_0)
          HAL_GPIO_WritePin(GPIOG,GPIO_PIN_13, GPIO_PIN_SET);       // green ON
#pragma GCC diagnostic pop
// ----------------------------------------------------------------------------