AnsweredAssumed Answered

External interrupt subroutine not being called !!!

Question asked by parthiban.kunal on Jan 18, 2013
Latest reply on Jan 23, 2013 by fm
I am trying to write a simple program to toggle an LED at PORTA.3 on trigger by an external interrupt on PORTB.0..a switch is attached to PORTB.0 for changing the state of Port.
I have done the initialization of interrupt and configured the GPIO port properly but still interrupt routine is not called. I am using the IAR workbench C compiler for flashing the code.What could be the mistake?
/**
  ******************************************************************************
  * @file    EXTI/main.c
  * @author  MCD Application Team
  * @version V3.3.0
  * @date    04/16/2010
  * @brief   Main program body
  ******************************************************************************
  * @copy
  *
  * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
  * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  *
  * <h2><center>© COPYRIGHT 2010 STMicroelectronics</center></h2>
  */
 
 
#include "stm32f10x.h"
#include "stm32f10x_gpio.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
GPIO_InitTypeDef GPIO_InitStructure;
void Delay(__IO uint32_t nCount);
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
void NVIC_Configuration(void);
void GPIO_Configuration(void);
void EXIT_Configuration(void);
 
int main()
{
 
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOA, ENABLE);
GPIO_Configuration();
EXIT_Configuration();
NVIC_Configuration();
//Infinite Loop
 
  GPIO_WriteBit(GPIOB,GPIO_Pin_14,Bit_SET);
    SysTick_Config(15000000);
  while (1)
  {
       
 
 
     
  }
}
 
     
void GPIO_Configuration(void)
{
  GPIO_InitTypeDef   GPIO_InitStructure;
 
   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(GPIOA, &GPIO_InitStructure);
     
      GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(GPIOB, &GPIO_InitStructure);
 
 
}
 
void EXIT_Configuration(void)
 
{
//SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOG, EXTI_PinSource7);
 
EXTI_InitTypeDef EXTI_InitStructure;
//*Connect Key1 button EXTI Line to key Button GPIO Pin */
GPIO_EXTILineConfig(GPIO_PortSourceGPIOB,GPIO_PinSource14);
//*Configure Key1 button EXTI Line to generate an Interrupt at falling Edge*/
EXTI_StructInit(&EXTI_InitStructure);
EXTI_InitStructure.EXTI_Line = EXTI_Line14;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
//* Generate softwar Interrrupt: simulöate a falling Edge applied on PA6 EXTI Line */
//// EXTI_Gene´rateSWInterrupt(EXTI_Line0);
 
}
 
void NVIC_Configuration(void)
{
 
////#ifdef VEST_TAB_RAM
//  /* Set the vector table location at 0x20000000 */
//  NVIC_SetVectorTable(NVIC_VectTAB_RAM,0x0);
//#else /*VEST_TAB_FLASH*/
//  /* Set the vector table location at 0x80000000 */
//   NVIC_SetVectorTable(NVIC_VectTab_FLASH,0x0);
//#endif
//  
 
 
   /* Enable External Interrupt*/
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x01;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x01;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
//Finally I have to create the interrupt handler. The EXTI2_IRQHandler handles external interrupts on lines 5 ~ 7. This method is actually defined in my CPUs startup assembly file as a weak reference. I just need to redefine the method and the linker will do the rest.
}
void EXTI15_10_IRQHandler(void)
{
    if(EXTI_GetITStatus(EXTI_Line14) != RESET)
    {
    GPIO_WriteBit(GPIOA,GPIO_Pin_4,Bit_SET);
    
    GPIO_WriteBit(GPIOA,GPIO_Pin_4,Bit_RESET);
     
     
    EXTI_ClearITPendingBit(EXTI_Line14);
        
    }
    
}
 
 
void Delay(__IO uint32_t nCount)
{
  for(; nCount != 0; nCount--);
   
}

Outcomes