AnsweredAssumed Answered

STM32F4 interrupt issue

Question asked by tybandara on Jan 2, 2013
Latest reply on Jan 3, 2013 by tybandara
Hello experts,

I'm using stm32f4 discovery board. I have connected an interrupt line from a RTC chip to PA1 of my board. The RTC chip gives interrupt signals each 1 second. The way I enable interrupts is as follows.

void RTC_INTERRUPT_Config(void)
{
  EXTI_InitTypeDef   EXTI_InitStructure;
  GPIO_InitTypeDef   GPIO_InitStructure;
  NVIC_InitTypeDef   NVIC_InitStructure;

  /* Enable GPIOG clock */
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
  /* Enable SYSCFG clock */
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
 
 
  /* Connect EXTI Line15 to PG15 pin */
  SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA, EXTI_PinSource1);
  /* Configure PG15 pin as input floating */
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
  GPIO_Init(GPIOA, &GPIO_InitStructure);


  EXTI_InitStructure.EXTI_Line = EXTI_Line1;
  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
  EXTI_InitStructure.EXTI_LineCmd = ENABLE;
  EXTI_Init(&EXTI_InitStructure);

  /* Enable and set EXTI15_10 Interrupt to the lowest priority */
  NVIC_InitStructure.NVIC_IRQChannel = EXTI1_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

  NVIC_Init(&NVIC_InitStructure);

}

My IRQ is as follows.

void EXTI1_IRQHandler(void)
{
  if(EXTI_GetITStatus(EXTI_Line1) != RESET)
  {
    /* Toggle LED4 */
    STM_EVAL_LEDToggle(LED4);
    /* Clear the EXTI line 0 pending bit */
    EXTI_ClearITPendingBit(EXTI_Line1);
        postState(RTC_ALARM_RECIEVED);
  }
}

My issue is when I just call the interrupt enabling function, I don't see any interrupts. But when I call
 
EXTI_GenerateSWInterrupt(EXTI_Line1);

just after the interrupt enabling function, everything works fine. But then there's another problem. When I just call the above method, it fires an interrupt even without my RTC interrupt line connected.

Please advice me on how to correctly configure this interrupt line. I'm asking this after trying lot's of examples and, I was unable to get a satisfying result yet.

Thank you for your time.

Thilina

Outcomes