AnsweredAssumed Answered

stm32f107vc - external interrupt problem

Question asked by arslan.bahadir on Oct 16, 2013
Latest reply on Oct 16, 2013 by Clive One
hello forum . I am trying to use external interrupt but I can't do it and I can't understand what is wrong.
here is my code :


#include "stm32f10x.h"
#include "stm32_eval.h"
#include <stdio.h>


GPIO_InitTypeDef gpio_initstructureled;
GPIO_InitTypeDef gpio_initstructurebutton;
EXTI_InitTypeDef exti_initstructureexternalinterrupt;
NVIC_InitTypeDef nvic_initstructure;


void EXTI9_5_IRQHandler()
{
     uint8_t leddurumu;
     leddurumu = GPIO_ReadInputDataBit(GPIOD,GPIO_Pin_7);
     if(leddurumu == Bit_SET)
     {GPIO_ResetBits(GPIOD,GPIO_Pin_7);}
     else
     {GPIO_SetBits(GPIOD,GPIO_Pin_7);}     
}






int main(void)
{
          RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD,ENABLE);
          RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);
          RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);

          gpio_initstructureled.GPIO_Pin = GPIO_Pin_7;
          gpio_initstructureled.GPIO_Mode = GPIO_Mode_Out_PP;
          gpio_initstructureled.GPIO_Speed = GPIO_Speed_50MHz;

          GPIO_Init(GPIOD,&gpio_initstructureled);



          gpio_initstructurebutton.GPIO_Pin = GPIO_Pin_9;
          gpio_initstructurebutton.GPIO_Mode = GPIO_Mode_IPU;
          gpio_initstructurebutton.GPIO_Speed = GPIO_Speed_50MHz;

          GPIO_Init(GPIOB,&gpio_initstructurebutton);
          GPIO_EXTILineConfig(GPIO_PortSourceGPIOB,GPIO_PinSource9);



          exti_initstructureexternalinterrupt.EXTI_Line = EXTI_Line9;
          exti_initstructureexternalinterrupt.EXTI_Mode = EXTI_Mode_Interrupt;
          exti_initstructureexternalinterrupt.EXTI_Trigger = EXTI_Trigger_Falling;
          exti_initstructureexternalinterrupt.EXTI_LineCmd = ENABLE;

          EXTI_Init(&exti_initstructureexternalinterrupt);


          nvic_initstructure.NVIC_IRQChannel = EXTI9_5_IRQn ;
          nvic_initstructure.NVIC_IRQChannelPreemptionPriority =0x0f;
          nvic_initstructure.NVIC_IRQChannelSubPriority = 0x0f;
          nvic_initstructure.NVIC_IRQChannelCmd = ENABLE ;

     NVIC_Init(&nvic_initstructure);
          


  while (1)
  {
  }
}






#ifdef  USE_FULL_ASSERT


/**
  * @brief  Reports the name of the source file and the source line number
  *         where the assert_param error has occurred.
  * @param  file: pointer to the source file name
  * @param  line: assert_param error line source number
  * @retval None
  */
void assert_failed(uint8_t* file, uint32_t line)

  /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */


  /* Infinite loop */
  while (1)
  {
  }
}
#endif

so Can you see any problem ? 
thanks for your help 

Outcomes