cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 interrupt issue

tybandara
Associate II
Posted on January 02, 2013 at 15:29

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

#interrupt #stm32f4 #discovery #external-interrupt
3 REPLIES 3
tybandara
Associate II
Posted on January 03, 2013 at 05:47

Someone please, I know this is a very simple thing. Yet I can't figure it out. I'm really stuck here

tybandara
Associate II
Posted on January 03, 2013 at 10:28

By the way I just checked the same code for the user button in Discovery board (PA0). And it's working fine. But it's not working for PA1. Please shed some light on this

tybandara
Associate II
Posted on January 03, 2013 at 13:27

Oops... Just figured it out. Bad coding. I had to clear the interrupt flags in the external RTC before enabling interrupt.