cancel
Showing results for 
Search instead for 
Did you mean: 

Software interrupt doesn't work - please help

igal
Associate II
Posted on September 09, 2013 at 17:04

Hi,

I try to set a software interrupt.

I set it as follows:

&sharpdefine HZ500_EXT_INT_LINE                                EXTI_Line1

&sharpdefine HZ500_EXT_INT_IRQ                                    EXTI1_IRQn

&sharpdefine HZ500_EXT_INT_PREEMPTION                    1

&sharpdefine HZ500_EXT_INT_SUB                                    2

void init_500hz_event_interrupt(void)

{

  EXTI_InitTypeDef   EXTI_InitStructure;

  NVIC_InitTypeDef   NVIC_InitStructure;

    

  /* Enable SYSCFG clock */

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);

 

  /* Configure EXTI Line1 */

  EXTI_InitStructure.EXTI_Line = HZ500_EXT_INT_LINE;

  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Event;

  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling;

  EXTI_InitStructure.EXTI_LineCmd = ENABLE;

  EXTI_Init(&EXTI_InitStructure);

    

  /* Enable and set EXTI1 Interrupt */

  NVIC_InitStructure.NVIC_IRQChannel = HZ500_EXT_INT_IRQ;

  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = HZ500_EXT_INT_PREEMPTION;

  NVIC_InitStructure.NVIC_IRQChannelSubPriority = HZ500_EXT_INT_SUB;

  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

    

  NVIC_Init(&NVIC_InitStructure);

}

I have an ISR routine that is triggered by an external interrupt and it should trigger the software interrupt, I use the following command in order to trigger the software interrupt:

EXTI_GenerateSWInterrupt(HZ500_EXT_INT_LINE);

Unfortunately the software interrupt is not trigered. Am I missing something?

The ISR for the interrupt routine is defined as follows:

&sharpdefine HZ500_EXT_INT_HANDLER                                                    EXTI1_IRQHandler

void HZ500_EXT_INT_HANDLER(void)

{

    static uint8_t hz_100_creation;

    

    EXTI_ClearITPendingBit(HZ500_EXT_INT_LINE);

    TOGGLE_TP23;

    read_ppg_led_registers();

    hz_100_creation++;

    if(hz_100_creation >= HZ_100_COUNT)

    {

        hz_100_creation = 0;

&sharpifdef RAW_DATA_MODE

        dls_dicmation();

&sharpelse

        dls_100hz_section();

&sharpendif /* RAW_DATA_MODE */

    }

    

}

Thank you for your help

#exti #event #stm32-exti-software-interrupt" #software-interrupt"
4 REPLIES 4
Posted on September 09, 2013 at 22:26

EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
igal
Associate II
Posted on September 10, 2013 at 08:29

But since SYSCFG_EXTICR1 = 0; transitions on PA1 will cause interrupt too, I don't want the external port to cause interrupt

igal
Associate II
Posted on September 10, 2013 at 10:17

I found a solution

I cancelled the lines:

EXTI_InitStructure.EXTI_Line = HZ500_EXT_INT_LINE;

EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Event;

EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling;

EXTI_InitStructure.EXTI_LineCmd = ENABLE;

EXTI_Init(&EXTI_InitStructure);

instead of using EXTI_GenerateSWInterrupt I use NVIC->STIR = HZ500_EXT_INT_IRQ;

Clive's solution works but it also causes external interrupt from the port and not only software interrupts, so it's not good for my purposes. I though setting the type to event will disable external interrupts but will enable software interrupts using EXTI_GenerateSWInterrupt. I was wrong.

If anyone has a better way of doing it or if my solution is not a healthy one I will be extremely happy to hear about it

Thank you

oliver23
Associate II
Posted on October 16, 2013 at 13:32

Hi

I have had the same problem and found another solution:

    EXTI->RTSR = 0x0000;

 

    EXTI->FTSR = 0x0000;

This will disable rising and falling edge trigger detection.

There will be no trigger from external pin.

I recommend updating the library to have this option, doing the above:

EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Software_Only;

I am open to other suggestions.