cinterruptstm32interrupt-handling

Multiple interrupts on the same EXTI Line STM32


Is it possible to get multiple interrupts from te same EXTI line for par example for PA1 and PC1 they are both on EXTI1.

So that by clicking on a button on PA1 a LED go on at PB6, And by clicking on PC1 that a LED toggle on PC0.

Microcontroller ==> STM32F091

That is the code that i use for interrupts from 2 different lines:

//PC1
SYSCFG->EXTICR[0] |= SYSCFG_EXTICR1_EXTI1_PA;
EXTI->IMR = EXTI_IMR_MR1;
EXTI->RTSR = EXTI_RTSR_TR1;
EXTI->FTSR = EXTI_FTSR_TR1; 

//PB0
SYSCFG->EXTICR[0] |= SYSCFG_EXTICR1_EXTI1_PC;
EXTI->IMR |= EXTI_IMR_MR1; 
EXTI->RTSR |= EXTI_RTSR_TR1; 
EXTI->FTSR |= EXTI_FTSR_TR1;

NVIC_EnableIRQ(EXTI0_1_IRQn);
NVIC_SetPriority(EXTI0_1_IRQn,0);

The interrupt Handler:

void EXTI0_1_IRQHandler(void)
{
  // Check line 1 has triggered the IT.
  if ((EXTI->PR & EXTI_PR_PR1) == EXTI_PR_PR1)
  {
    EXTI->PR = EXTI_PR_PR1; // Clear the pending bit.
    GPIOC->ODR ^= 1 << 0;
  }

  // Check line 0 has triggered  the IT.
  if ((EXTI->PR & EXTI_PR_PR0) == EXTI_PR_PR0)
  {
    EXTI->PR = EXTI_PR_PR0; // Clear the pending bit.
    GPIOB->ODR ^= 1 << 6;
  }
}

Solution

  • No, you can't. Sorry.

    Each of the 16 GPIO-driven EXTIs can only be connected to one of the six corresponding pins. For instance, EXTI0 can be connected to PA0, PB0, PC0, PD0, PE0, or PF0, etc. Values like SYSCFG_EXTICR1_EXTI1_PA are not pure bitmasks, and cannot be combined.

    enter image description here

    For additional details, see section 12.2.5 of the STM32F0 reference manual.