AnsweredAssumed Answered

EXTI0_1_IRQ and EXTI4_15_IRQ don't work independent ?

Question asked by richter.andrey on Nov 4, 2017
Latest reply on Nov 5, 2017 by waclawek.jan

Hello everybody,

 

I use two interrupts in the STM32F051K4 MCU.

There are EXTI0_1_IRQ and EXTI4_15_ORQ.

With EXTI0 will be PA0 used (Hall sensor) and to EXTI4_15 are PB5, PB6, PB7 Pins (user keys) connected.

Both interrupts work independently very well, but wenn I try to use EXTI0 and EXTI4_15 together (any key will be pressed and EXTI4_15 ocurred) break EXTI0 to work.

My question is : can I use by STM32F051K4 different Ports for for different EXTI-Lines ? For example in my case I use PA0 for EXTI0_1 Interrupt and PB7, PB6, PB5 for EXTI4_15 Interrupt.

 

Thank you for your help!

.

Initialisation code listed below:

 

 

void exti_exti0_1Config(void)
{
  /* Enable GPIOA clock */   // already done in gpioctrl.c
  //RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);

  /* Enable SYSCFG clock */
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);


  /* Configure PA0 */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_Init(GPIOA, &GPIO_InitStructure);

  /* Connect EXTI0 to pin Sensor Event*/
  SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA, EXTI_PinSource0);


  /* Configure EXTI0 line */
  EXTI_InitStructure.EXTI_Line = EXTI_Line0;
  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 EXTI0 Interrupt */
  NVIC_InitStructure.NVIC_IRQChannel = EXTI0_1_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPriority = 0x2;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
}


void exti_exti4_15Config(void)
{
  /* Enable GPIOB clock */
  //RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);
  /* Enable SYSCFG clock */
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);


  /* Configure PB7, PB6, PB5 pin as input floating */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_6 | GPIO_Pin_5;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_Init(GPIOB, &GPIO_InitStructure);

  /* Connect EXTI7, 6, 5 Line to PB7, PB6, PB5 pin Sensor Event*/
  //SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOB, EXTI_PinSource7 | EXTI_PinSource6 | EXTI_PinSource5);
  SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOB, EXTI_PinSource7);
  SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOB, EXTI_PinSource6);
  SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOB, EXTI_PinSource5);


  /* Configure EXTIx line */
  EXTI_InitStructure.EXTI_Line = EXTI_Line7 | EXTI_Line6 | EXTI_Line5;
  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 EXTI1 Interrupt */
  NVIC_InitStructure.NVIC_IRQChannel = EXTI4_15_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPriority = 0x3;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);

}


void EXTI0_1_IRQHandler(void)
{
    NVIC_DisableIRQ(EXTI0_1_IRQn);
   
    // Hall1 signal
    if(EXTI_GetITStatus(EXTI_Line0) != RESET)
    {
        /* Clear the EXTI line 5 pending bit */
        EXTI_ClearITPendingBit(EXTI_Line0);
   
        switchVar = ~switchVar; // just for debugging purpose
        if(switchVar)
        {          

            GPIOA->BSRR |= GPIO_Pin_12; // set green LED on
        }
        else
        {          

            GPIOA->BRR |= GPIO_Pin_12; // set green LED on
        }

    }
   
    // Hall2 signal
    if(EXTI_GetITStatus(EXTI_Line1) != RESET)
    {
        /* Clear the EXTI line 6 pending bit */
        EXTI_ClearITPendingBit(EXTI_Line1);
       
        // To Do: clear blockade timer der auf ca. 180 - 200ms eingestellt ist
        //sw_getSwCtrl()->flHall2Ev = 1;
    }
    NVIC_EnableIRQ(EXTI0_1_IRQn);

}


void EXTI4_15_IRQHandler(void)
{
    NVIC_DisableIRQ(EXTI4_15_IRQn); // IRQ will bei in keyctrl.c Module enabled

    if(EXTI_GetITStatus(EXTI_Line5) != RESET)
    {
        /* Clear the EXTI line 5 pending bit */
        EXTI_ClearITPendingBit(EXTI_Line5);
        // set key press flag as TRUE
        key_getKeyCtrl()->biKeyPresRelInt = TRUE;
    }
   
    if(EXTI_GetITStatus(EXTI_Line6) != RESET)
    {
        /* Clear the EXTI line 6 pending bit */
        EXTI_ClearITPendingBit(EXTI_Line6);
        // set key press flag as TRUE
        key_getKeyCtrl()->biKeyPresRelInt = TRUE;
    }
   
    if(EXTI_GetITStatus(EXTI_Line7) != RESET)
    {
        /* Clear the EXTI line 7 pending bit */
        EXTI_ClearITPendingBit(EXTI_Line7);
        // set key press flag as TRUE
        key_getKeyCtrl()->biKeyPresRelInt = TRUE;
    }
   
    // IRQ will bei in keyctrl.c Module enabled
    //NVIC_EnableIRQ(EXTI4_15_IRQn);
}

Outcomes