EXTI - single execution (one shot)

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
User avatar
Skadi
Posts: 60
Joined: Fri Apr 17, 2015 5:10 pm
Has thanked: 4 times
Been thanked: 3 times

EXTI - single execution (one shot)

Post 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
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: EXTI - single execution (one shot)

Post 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
User avatar
Skadi
Posts: 60
Joined: Fri Apr 17, 2015 5:10 pm
Has thanked: 4 times
Been thanked: 3 times

Re: EXTI - single execution (one shot)

Post 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
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: EXTI - single execution (one shot)

Post 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
Post Reply