AnsweredAssumed Answered

EXTI0_IRQHandler

Question asked by Baev.Alexander on Aug 15, 2014
Latest reply on Aug 19, 2014 by Clive One
Dear friends. Show me please my mistake. When I debug the following program I even cannot get to ISR... I stay in infinite loop...
Thanks!
void EXTI0_IRQHandler (void);

int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured,
       this is done through SystemInit() function which is called from startup
       files (startup_stm32f429_439xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f4xx.c file
     */  
 
  /* Add your application code here */
    
  /* Infinite loop */
 
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOG, ENABLE); //Clck to GPIOG
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
  SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA, EXTI_PinSource0);
 
 
  GPIO_InitTypeDef PortG_init, PortA_init;
 
  PortG_init.GPIO_Mode = GPIO_Mode_OUT;
  PortG_init.GPIO_OType = GPIO_OType_PP;
  PortG_init.GPIO_Pin = GPIO_Pin_13;
  PortG_init.GPIO_PuPd = GPIO_PuPd_NOPULL;
  PortG_init.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(GPIOG, &PortG_init);
 
  PortA_init.GPIO_Mode = GPIO_Mode_IN;
  PortA_init.GPIO_OType = GPIO_OType_PP;
  PortA_init.GPIO_Pin = GPIO_Pin_0;
  PortA_init.GPIO_PuPd = GPIO_PuPd_NOPULL;
  PortA_init.GPIO_Speed = GPIO_Low_Speed;
  GPIO_Init(GPIOA, &PortA_init); //GPIOA_Pin_0 as input
 
 
 
  EXTI_InitTypeDef PortA_Pin0;
 
  PortA_Pin0.EXTI_Line = EXTI_Line0;
  PortA_Pin0.EXTI_Mode = EXTI_Mode_Interrupt;
  PortA_Pin0.EXTI_Trigger = EXTI_Trigger_Rising;
  PortA_Pin0.EXTI_LineCmd = ENABLE;
  EXTI_Init(&PortA_Pin0);
 
  NVIC_InitTypeDef NVIC_PortA;
 
  NVIC_PortA.NVIC_IRQChannel = EXTI0_IRQn;
  NVIC_PortA.NVIC_IRQChannelPreemptionPriority = 0x01;
  NVIC_PortA.NVIC_IRQChannelSubPriority = 0x01;
  NVIC_PortA.NVIC_IRQChannelCmd = ENABLE;
 
  NVIC_Init(&NVIC_PortA);
 
   
 
  while (1)
  {
    
  }     
}

void EXTI0_IRQHandler (void)
{
  GPIO_ToggleBits(GPIOG, GPIO_Pin_13);
//  delay(1000000);
  EXTI_ClearITPendingBit(EXTI_Line0);
}


Interesting thing...I'm working in IAR.
When I was debugging watching locals in this part:

PortA_Pin0.EXTI_Line = EXTI_Line0;
  PortA_Pin0.EXTI_Mode = EXTI_Mode_Interrupt;
  PortA_Pin0.EXTI_Trigger = EXTI_Trigger_Rising;
  PortA_Pin0.EXTI_LineCmd = ENABLE;
  EXTI_Init(&PortA_Pin0);

PortA_Pin0.EXTI_LineCmd = ENABLE stayed DISABLED until I didn't changed compiler optimization from high to medium....
What didn't I take into account?
Watching for other bugs....

Outcomes