AnsweredAssumed Answered

user button interrupt (STM32F091)

Question asked by perun.raphael on May 21, 2015
Latest reply on May 21, 2015 by Forever_Embedded
hello !

I tried to make work an interrupt subroutine by pressing on user  button present on the nucleo f091rc...

I wrote into "stm32f0xx_exti.c" the function EXTI13_Config() as shown in code example :

void EXTI13_Config(void)
    EXTI_InitTypeDef   EXTI_InitStructure;
    NVIC_InitTypeDef   NVIC_InitStructure;
    GPIO_InitTypeDef   GPIO_InitStructure;
    /* Enable GPIOC clock */

  /* Enable SYSCFG clock */
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
    /* Configure PC8 and PC13 pins as input floating */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_Init(GPIOC, &GPIO_InitStructure);
    /* Connect EXTI13 Line to PC13 pin */
  SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOC, EXTI_PinSource13);
    /* Configure EXTI13 line */
    EXTI_InitStructure.EXTI_Line = EXTI_Line13;
    EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling;
  EXTI_InitStructure.EXTI_LineCmd = ENABLE;
    /* Enable and set EXTI4_15 Interrupt */
  NVIC_InitStructure.NVIC_IRQChannel = EXTI4_15_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPriority = 0x00;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

I declare the prototype in header file exti.h

here is my main

#include "stm32f0xx.h"   // Device header
#include "system_stm32f0xx.h"
#include "stm32f0xx_rcc.h"
#include "stm32f0xx_spi.h"
#include "stm32f0xx_gpio.h"
#include "stm32f0xx_usart.h"
#include "stm32f0xx_adc.h"
#include "stm32f0xx_dac.h"
#include "stm32f0xx_exti.h"
#include "sweep.h"
#include "main.h"
#include "data.h"

int main (void){
/*my code*/


void EXTI13_IRQHandler(void)
            if(EXTI_GetITStatus(EXTI_Line13) != RESET)
    uint32_t FDDS[4]={10307921,34359738,68719476,343597383};
    static uint8_t i=0;
    SPI_sendData40_DDS(FDDS[i], 0x00);

the functions called in my interrupt subroutine are ok, i used them in my while(1) loop. I didn't show the content of the while(1) loop because it is long and would have make this post too much long...

As you can see on my ISR I try to turn on the led once the button (connected to PC13) is pressed. Unfortunately it never turn on... If someone see my mistake, I'll be gratefull for his help.
Thank you