cancel
Showing results for 
Search instead for 
Did you mean: 

EXTI interrupt on PA5 give faulty interupt at PA6(as GPIO configure).Using STM32f4 discovery kit

aliahmedansari
Associate
Posted on June 22, 2012 at 08:38

In main function when we set or reset PA6, it will land into interrupt, while I have explicitly defined in EXTI9_5_IRQHandler , that only interrupt should happen on PA5 not on PA6. I don't know what is going on Please Help??, I want PA6 as GPIO alone (not on interrupt) and PA5 input as an interrupt, plz see code below

//Code is here::::::

void EXTILine5_Config(void)

{  

  EXTI_InitTypeDef   EXTI_InitStructure;

  NVIC_InitTypeDef   NVIC_InitStructure;

  /* Enable GPIOA clock */

  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);

  /* Enable SYSCFG clock */

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);

 

  /* Configure PA5 pin as input floating */

 

  /* Connect EXTI Line5 to PA5 pin */

  SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA, EXTI_PinSource5);

  /* Configure EXTI Line0 */

  EXTI_InitStructure.EXTI_Line = EXTI_Line5;

  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 EXTI Line5 Interrupt to the lowest priority */

  NVIC_InitStructure.NVIC_IRQChannel =EXTI9_5_IRQn;

  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x01;

  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x01;

  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

  NVIC_Init(&NVIC_InitStructure);

}

void InitGPIOS(void)

{

 

/* Configure PA6 in output pushpull mode */

 

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;

  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

  GPIO_Init(GPIOA, &GPIO_InitStructure); /// GPIO PA6

    /* Configure PA5 in input pushpull mode */

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;

  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;

  GPIO_Init(GPIOA, &GPIO_InitStructure);

}

void Delay(__IO uint32_t nTime)

{

  TimingDelay = nTime;

  while(TimingDelay != 0);

 

}

void TimingDelay_Decrement(void)

{

  if (TimingDelay != 0x00)

  {

    TimingDelay--;

  }

}

void main(){

    InitGPIOS();

    EXTILine5_Config();

    while(1)

    {

        GPIO_WriteBit(GPIOA, GPIO_Pin_6,Bit_SET);

        Delay(100);

        GPIO_WriteBit(GPIOA, GPIO_Pin_6,Bit_RESET);

        Delay(100);

    }

}

//                             GPIO Interrupt

void EXTI9_5_IRQHandler(void)

{    

    if(EXTI_GetITStatus(EXTI_Line5) != RESET)

    {

        STM_EVAL_LEDToggle(LED4);

        EXTI_ClearITPendingBit(EXTI_Line5);

    }

}

Thanks in advance

#exti-interrupt-error
0 REPLIES 0