Page 1 of 1

EXTI - single execution (one shot)

Posted: Tue Apr 11, 2017 1:13 pm
by Skadi
Hi,

I implemented an extrenal interrupt, which is configured as followed:

Code: Select all

static EXTConfig extern_interrupt_config = { {
        {EXT_CH_MODE_DISABLED, NULL},
        {EXT_CH_MODE_DISABLED, NULL},
        {EXT_CH_MODE_DISABLED, NULL},
        {EXT_CH_MODE_DISABLED, NULL},
        {EXT_CH_MODE_DISABLED, NULL},
        {EXT_CH_MODE_DISABLED, NULL},
        {EXT_CH_MODE_DISABLED, NULL},
        {EXT_MODE_GPIOC | EXT_CH_MODE_RISING_EDGE | EXT_CH_MODE_AUTOSTART, adc_sync_callback},         /* Pin PC7 */
        {EXT_CH_MODE_DISABLED, NULL},
        {EXT_CH_MODE_DISABLED, NULL},
        {EXT_CH_MODE_DISABLED, NULL},
        {EXT_CH_MODE_DISABLED, NULL},
        {EXT_CH_MODE_DISABLED, NULL},
        {EXT_CH_MODE_DISABLED, NULL},
        {EXT_CH_MODE_DISABLED, NULL},
        {EXT_CH_MODE_DISABLED, NULL},
        {EXT_CH_MODE_DISABLED, NULL},
        {EXT_CH_MODE_DISABLED, NULL},
        {EXT_CH_MODE_DISABLED, NULL},
        {EXT_CH_MODE_DISABLED, NULL},
        {EXT_CH_MODE_DISABLED, NULL},
        {EXT_CH_MODE_DISABLED, NULL},
        {EXT_CH_MODE_DISABLED, NULL}
} };


The callback function:

Code: Select all

void adc_sync_callback (EXTDriver *ext_driver, expchannel_t channel){

    (void)ext_driver;
    (void)channel;

    chSysLockFromISR();

    Do_Someting();

    extChannelDisableI(&EXTD1, 7);
    chSysUnlockFromISR();

}


The "execution" in the main programm:

Code: Select all

  extStart(&EXTD1, &extern_interrupt_config);
  extChannelEnable(&EXTD1, 7);



The extrenal interrupt works, but it is executed twice. I tried to set the interrupt pending bit to 1 (as stated in the reference manuel on page 388) by

Code: Select all

EXTI->PR |= 0x00000010;
but it makes no difference.

How can I achive a single execution?

BR Skadi

Re: EXTI - single execution (one shot)

Posted: Tue Apr 11, 2017 1:48 pm
by Giovanni
Hi,

EXTI is edge sensitive, not sure what is going on there.

Status flags are cleared by the driver, you don't need to do that yourself.

Giovanni

Re: EXTI - single execution (one shot)

Posted: Tue Apr 11, 2017 2:00 pm
by Skadi
Hi Giovanni,

I know, EXTI is edge sensitive. In may case I set the trigger sensitive to an rising edge.

An clock signal is attached to the extrenal trigger pin, thus I disable the interrupt inside callback function. Unfortunately the callback function is executed twice instead of a single time.

So if the status flags are cleared by the driver, why is the callback function executed twice?

BR
Skadi

Re: EXTI - single execution (one shot)

Posted: Tue Apr 11, 2017 2:22 pm
by Giovanni
The channel disable function clears the PR register so I don't see how you are getting another callback.

I don't see anything in the code that could trigger that.

Try to write a test application that is triggered by the board button then disables the channel. See if you get the same behavior.

Giovanni