cancel
Showing results for 
Search instead for 
Did you mean: 

user button interrupt (STM32F091)

raphael
Associate II
Posted on May 21, 2015 at 09:01

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 */

  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);

  /* 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;

  EXTI_Init(&EXTI_InitStructure);

    

    /* Enable and set EXTI4_15 Interrupt */

  NVIC_InitStructure.NVIC_IRQChannel = EXTI4_15_IRQn;

  NVIC_InitStructure.NVIC_IRQChannelPriority = 0x00;

  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

  NVIC_Init(&NVIC_InitStructure);

}

+

I declare the prototype in header file exti.h

+

here is my main

&sharpinclude ''stm32f0xx.h''   // Device header

&sharpinclude ''system_stm32f0xx.h''

&sharpinclude ''stm32f0xx_rcc.h''

&sharpinclude ''stm32f0xx_spi.h''

&sharpinclude ''stm32f0xx_gpio.h''

&sharpinclude ''stm32f0xx_usart.h''

&sharpinclude ''stm32f0xx_adc.h''

&sharpinclude ''stm32f0xx_dac.h''

&sharpinclude ''stm32f0xx_exti.h''

&sharpinclude ''sweep.h''

&sharpinclude ''main.h''

&sharpinclude ''data.h''

int main (void){

EXTI13_Config();

while(1)

{

/*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;

    led1_on();

    if(i==3)i=0;

    SPI_sendData40_DDS(FDDS[i], 0x00);

    i++;    

  EXTI_ClearFlag(EXTI_Line13);

 }

}

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

#interrupt #stm32 #exti #button
2 REPLIES 2
Posted on May 21, 2015 at 09:27

> void EXTI13_IRQHandler(void)

There is no such, use EXTI4_15_IRQHandler()

JW

ceylan
Associate II
Posted on May 21, 2015 at 14:02

please, open your startup folder after then you look to interrupt function name:-)