AnsweredAssumed Answered

PC2 Line2 causing an EXTI interrupt on PC3 Line3

Question asked by prieur.jean on Jul 17, 2014
Hello everybody,

I have a problem with one of my EXTI interrupt. I have two hardware switches, one is linked to the PC2 PIN, the other is linked to the PC3 pin. I also configure EXTI interrupts on the PC2 and PC3 (so Line2 and Line3).

- When I press the PC3 switch, I have as expected an interrupt on EXTI3_IRQHandler.
- When I press the PC2, I have an interrupt on EXTI2_IRQHandler, but sometime also an interrupt on EXTI3_IRQHandler (about one in five times).

I don't understand why, because the PC3 and PC2 tracks are not linked together on my board. When I press the PC2 switch, PC2 pin = 5V and the PC3 pin is always 0V.

I think I try every GPIO definition but nothing change. This is my code:

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);

void Interrupt_Config_Line3(void)
{
    // INIT TYPEDEF
    NVIC_InitTypeDef NVIC_InitStructure;
    EXTI_InitTypeDef EXTI_InitStructure;
    // Connect EXTI Line3 to PC3 pin
    SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOC, EXTI_PinSource3);
    // Configure EXTI Line3
    EXTI_InitStructure.EXTI_Line = EXTI_Line3;
    EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
    EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
    EXTI_InitStructure.EXTI_LineCmd = ENABLE;
    EXTI_Init(&EXTI_InitStructure);
    // Enable and set EXTI Line3 Interrupt to the high priority
    NVIC_InitStructure.NVIC_IRQChannel = EXTI3_IRQn;
    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = PREAMPTION_PRIORITY_HIGH;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x00;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&NVIC_InitStructure);
}
 
void Interrupt_Config_Line2(void)
{
    // INIT TYPEDEF
    NVIC_InitTypeDef NVIC_InitStructure;
    EXTI_InitTypeDef EXTI_InitStructure;
    // Connect EXTI Line2 to PC2 pin
    SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOC, EXTI_PinSource2);
    // Configure EXTI Line2
    EXTI_InitStructure.EXTI_Line = EXTI_Line2;
    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 Line2 Interrupt to the low priority
    NVIC_InitStructure.NVIC_IRQChannel = EXTI2_IRQn;
    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = PREAMPTION_PRIORITY_LOW;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x00;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&NVIC_InitStructure);
}

void EXTI3_IRQHandler(void)
{
    if(EXTI_GetITStatus(EXTI_Line3) != RESET)
    {
        // Do something
        EXTI_ClearITPendingBit (EXTI_Line3);
    }
}
 
void EXTI2_IRQHandler(void)
{
    if(EXTI_GetITStatus(EXTI_Line2) != RESET)
    {
 
                 // Do something
    EXTI_ClearITPendingBit (EXTI_Line2);
    }
}

Do you have any ideas? Thanks a lot!

Outcomes