EXTI Driver

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: utzig, lbednarz, tfAteba, barthess, RoccoMarco

Tabulous
Posts: 462
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 1 time
Been thanked: 13 times

EXTI Driver

Postby Tabulous » Sun Mar 16, 2014 5:16 pm

Code: Select all

static const EXTConfig extcfg = {
  {
    {EXT_CH_MODE_BOTH_EDGES | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOE, extcb3},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_BOTH_EDGES | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOH, extcb1},
    {EXT_CH_MODE_BOTH_EDGES | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOH, extcb2},
    {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},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL}
  }
};


Above is my cfg structure for EXTI driver. Everything works ok apart from i get triggers when my application starts up.

In my application the inputs to the MCU can be switched on/off for low power reasons, thus my application starts up, enables the power to the inputs. The quiescent state of these inputs is high. But i find that as soon as i call extStart(&EXTD1, &extcfg); i get triggers on extcb1 and extcb2. I dont get any on extcb3 as this inputs quiescent state is low.

Is there away i can stop this happening ? Its like the driver assumes the default input state is low.

User avatar
Giovanni
Site Admin
Posts: 13074
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 758 times
Been thanked: 637 times
Contact:

Re: EXTI Driver

Postby Giovanni » Sun Mar 16, 2014 6:39 pm

Are you sure you aren't simply getting noise or very brief pulses on the inputs?

Giovanni

Tabulous
Posts: 462
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 1 time
Been thanked: 13 times

Re: EXTI Driver

Postby Tabulous » Sun Mar 16, 2014 6:45 pm

Giovanni wrote:Are you sure you aren't simply getting noise or very brief pulses on the inputs?

Giovanni


Definatly not noise as the the input that is quiescent state low does not suffer from this issue

User avatar
Giovanni
Site Admin
Posts: 13074
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 758 times
Been thanked: 637 times
Contact:

Re: EXTI Driver

Postby Giovanni » Sun Mar 16, 2014 7:10 pm

When the application starts, probably there is a transition from low to high on those inputs, is it possible you are getting that? also look for application notes about EXTI, the driver does nothing but call a function when an interrupt is triggered.

Giovanni

Tabulous
Posts: 462
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 1 time
Been thanked: 13 times

Re: EXTI Driver

Postby Tabulous » Mon Mar 17, 2014 8:52 am

Giovanni wrote:When the application starts, probably there is a transition from low to high on those inputs, is it possible you are getting that? also look for application notes about EXTI, the driver does nothing but call a function when an interrupt is triggered.

Giovanni



There is a transition from low to high, this is where i turn on the input driver hardware. But i want to ignore that transistion but i'm not able to, and i'm not sure if the EXTI driver will allow me to ?

Basically so far i have tried this

Power System ON, Inputs to the MCU are low.
Enable Power to the Input Driver Hardware, at this point the inputs to the MCU are high.
Delay 1 second to let Input Driver Hardware settle.
Call extStart(&EXTD1, &extcfg);

After the call to extStart the callbacks are fired, but there as not been any transistions, only the ones previous at startup prior to extStart was called, but i delayed the start to try and remove these ?

Also worth nothing if i start up the offending channels with EXT_CH_MODE_FALLING_EDGE, i dont get the false trigger.

User avatar
Giovanni
Site Admin
Posts: 13074
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 758 times
Been thanked: 637 times
Contact:

Re: EXTI Driver

Postby Giovanni » Mon Mar 17, 2014 9:36 am

Could you try to reset the SR register at the end of the ext_lld_start() function? You can see the code in ext_lld_stop().

Giovanni

Tabulous
Posts: 462
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 1 time
Been thanked: 13 times

Re: EXTI Driver

Postby Tabulous » Mon Mar 17, 2014 9:57 am

Giovanni wrote:Could you try to reset the SR register at the end of the ext_lld_start() function? You can see the code in ext_lld_stop().

Giovanni


Do you mean PR as in EXTI->PR ?

If so i tried this and it did not do anything, still get the trigger here is what i did

Code: Select all

static msg_t ThreadIO(void *arg)
{
Thread *p;
struct iom *m;


    (void)arg;

    chRegSetThreadName("IO");

    /*
     * Activates the EXT driver.
     */
    chThdSleepMilliseconds(1000); // wait for Hardware Driver to Settle

    extStart(&EXTD1, &extcfg);
    EXTI->PR = 0xFFFFFFFF;

    extChannelEnable(&EXTD1, 0);
    extChannelEnable(&EXTD1, 2);
    extChannelEnable(&EXTD1, 3);

    while(TRUE)
    {
    chThdSleepMilliseconds(1000);
    }
}

User avatar
Giovanni
Site Admin
Posts: 13074
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 758 times
Been thanked: 637 times
Contact:

Re: EXTI Driver

Postby Giovanni » Mon Mar 17, 2014 11:59 am

You have to put that line at the end of ext_lld_start() not after extStart() or the register is cleared after the interrupts have been enabled.

Giovanni

Tabulous
Posts: 462
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 1 time
Been thanked: 13 times

Re: EXTI Driver

Postby Tabulous » Mon Mar 17, 2014 12:43 pm

Giovanni wrote:You have to put that line at the end of ext_lld_start() not after extStart() or the register is cleared after the interrupts have been enabled.

Giovanni


Code: Select all

void ext_lld_start(EXTDriver *extp) {
  unsigned i;

  if (extp->state == EXT_STOP)
    ext_lld_exti_irq_enable();

  /* Configuration of automatic channels.*/
  for (i = 0; i < EXT_MAX_CHANNELS; i++)
    if (extp->config->channels[i].mode & EXT_CH_MODE_AUTOSTART)
      ext_lld_channel_enable(extp, i);
    else
      ext_lld_channel_disable(extp, i);

  EXTI->PR  = 0xFFFFFFFF;
}


does not make any differnece, still get the false trigger.

Also tried this, as wanted to make sure PR is been set

Code: Select all

    uint32_t temp1 = EXTI->PR;
    EXTI->PR = 0xFFFFFFFF;
    uint32_t temp2 = EXTI->PR;



temp1 and temp2 are always 0x0

User avatar
Giovanni
Site Admin
Posts: 13074
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 758 times
Been thanked: 637 times
Contact:

Re: EXTI Driver

Postby Giovanni » Mon Mar 17, 2014 1:40 pm

This should mean that the front is detected after the call to extStart(), there is no interrupt pending at that point.

Giovanni


Return to “General Support”

Who is online

Users browsing this forum: No registered users and 8 guests