cancel
Showing results for 
Search instead for 
Did you mean: 

Utillizing EXTI Interrupt

senayati
Associate II
Posted on May 03, 2010 at 22:42

Utillizing EXTI Interrupt

7 REPLIES 7
mozra272
Associate II
Posted on May 17, 2011 at 15:08

Hi,

You don't need to reconfigure the GPIO and EXTI to detect the rising and falling edge on the Pin...

you can configure the EXTI Sensitivity to Interrupt on Rising and Falling edges only in the main and in the interrupt check the pin status.

you can add this configuration in the main file

   GPIO_DeInit((GPIO_TypeDef*) CIP_GPIO_PIN);

   GPIO_Init(CIP_GPIO_PORT, CIP_GPIO_PIN, GPIO_Mode_In_PU_IT);

   EXTI_SetPinSensitivity(CIP_GPIO_PIN, EXTI_Trigger_Rising_Falling );

update the interrupt as following:

 

#ifdef _COSMIC_

@far @interrupt void EXTI7_IRQHandler(void)

#else /* _RAISONANCE_ */

void EXTI7_IRQHandler(void) interrupt 15

#endif /* _COSMIC_ */

{

    /* In order to detect unexpected events during development,

       it is recommended to set a breakpoint on the following instruction.

    */

 if ((GPIO_ReadInputDataBit((GPIO_TypeDef*) CIP_GPIO_PORT, CIP_GPIO_PIN)) != RESET)

 {

   cartState = NOT_PRESENT;

  }

  else

  {

   cartState = PRESENT;

  }

  /* Cleat Interrupt pending bit */

  EXTI_ClearITPendingBit(EXTI_IT_Pin7);   

}

Regards

mozra

senayati
Associate II
Posted on May 17, 2011 at 15:08

Hello Mozra,

Thank you for your reply. With the code you offered I get only interrupts on the falling edge and then it keeps interrupting while the PD7 is low and as the result the MCU is kept busy and using the resources to the point hat it does not have enough time to execute the part of the code in the main () function that associates with the cartState = PRESENT.

Regards,

Sia

From: mozra27

Posted: Tuesday, May 04, 2010 12:06 AM

Subject: Utillizing EXTI Interrupt

Hi,

You don't need to reconfigure the GPIO and EXTI to detect the rising and falling edge on the Pin...

you can configure the EXTI Sensitivity to Interrupt on Rising and Falling edges only in the main and in the interrupt check the pin status.

you can add this configuration in the main file

   GPIO_DeInit((GPIO_TypeDef*) CIP_GPIO_PIN);

   GPIO_Init(CIP_GPIO_PORT, CIP_GPIO_PIN, GPIO_Mode_In_PU_IT);

   EXTI_SetPinSensitivity(CIP_GPIO_PIN, EXTI_Trigger_Rising_Falling );

update the interrupt as following:

 

#ifdef _COSMIC_

@far @interrupt void EXTI7_IRQHandler(void)

#else /* _RAISONANCE_ */

void EXTI7_IRQHandler(void) interrupt 15

#endif /* _COSMIC_ */

{

    /* In order to detect unexpected events during development,

       it is recommended to set a breakpoint on the following instruction.

    */

 if ((GPIO_ReadInputDataBit((GPIO_TypeDef*) CIP_GPIO_PORT, CIP_GPIO_PIN)) != RESET)

 {

   cartState = NOT_PRESENT;

  }

  else

  {

   cartState = PRESENT;

  }

  /* Cleat Interrupt pending bit */

  EXTI_ClearITPendingBit(EXTI_IT_Pin7);   

}

Regards

mozra

mozra272
Associate II
Posted on May 17, 2011 at 15:08

Hi,

Please make sure that the pending bit is cleared and you don't have an other interrupt on Portx pin7:

  /* Clear Interrupt pending bit */

  EXTI_ClearITPendingBit(EXTI_IT_Pin7);

The  exti sensitivity configuration ( EXTI_Trigger_Rising_Falling) interrupting only on the edge.

Regards

mozra

Olga DIAMANTE
Associate II
Posted on May 17, 2011 at 15:08

You need just to reverse the instruction:

1. Set Pin sensitivity 

 EXTI_SetPinSensitivity(CIP_GPIO_PIN, EXTI_Trigger_Rising);

2. Configure PD7 as interrupt

GPIO_Init(CIP_GPIO_PORT, CIP_GPIO_PIN, GPIO_Mode_In_PU_IT);   

Let me know...

Ciao,

  Olga

durr
Associate II
Posted on May 17, 2011 at 15:08

Hi,

Has anyone found a solution to this problem? I have exactly the same problem.. and none of the solutions mentioned work for me.

lowpowermcu
Associate II
Posted on May 17, 2011 at 15:08

Hi robin,

In the reference manual I have found the following note;

''These bits can only be written when I1 and I0 in the CCR register are both set to 1 (level 3).''

In my understanding, this means that you can't change the EXTI configuration inside an interrupt.

I don't know the status of I1 and I0 bits inside interrupt so perhaps that could be the root.

Tell me if it is the root or not.

good luck

regards,

MCU Lüfter

durr
Associate II
Posted on May 17, 2011 at 15:08

Ok... I found a solution that works for me (after about 6hrs of messing around)

1. You HAVE to disable the interrupts before setting the pin sensitivity!

2. Make sure the interrupt is cleared before leaving routine...

Example:

Setting up Interrupt:

disableInterrupts();

   

    GPIO_DeInit((GPIO_TypeDef*) GPIO_Pin_6);

   

    EXTI_SetPinSensitivity(EXTI_Pin_6 , EXTI_Trigger_Rising_Falling);

   

    while(EXTI_GetPinSensitivity(EXTI_Pin_6) != EXTI_Trigger_Rising_Falling)

    {

      temp++;

    }

   

    GPIO_Init(GPIOE, GPIO_Pin_6, GPIO_Mode_In_FL_IT );

   

    enableInterrupts();

Interrupt Routine:

@far @interrupt void EXTI6_IRQHandler(void)

{

  uint16_t temp = 0;

 

  EXTI_ClearITPendingBit(EXTI_IT_Pin6); 

 

  while(EXTI_GetITStatus(EXTI_IT_Pin6) != RESET)

  {

    temp++;

  }

}

Hope that helps!