Page 1 of 1

EXTI same callback for differents pin - VT Instability

Posted: Thu Feb 21, 2013 2:14 pm
by Debbio
Hi at all,

My design on EXTI on STM32F205:

Code: Select all

    {EXT_CH_MODE_RISING_EDGE | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOA, cbExtImpulsi},
   {EXT_CH_MODE_RISING_EDGE | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOA, cbExtImpulsi},
   {EXT_CH_MODE_DISABLED, NULL},
   {EXT_CH_MODE_DISABLED, NULL},
   {EXT_CH_MODE_DISABLED, NULL},
   {EXT_CH_MODE_RISING_EDGE | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOB, cbExtImpulsi},
   {EXT_CH_MODE_RISING_EDGE | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOB, cbExtImpulsi},
   {EXT_CH_MODE_RISING_EDGE | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOB, cbExtImpulsi},
   {EXT_CH_MODE_RISING_EDGE | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOB, cbExtImpulsi},
   {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}


As you noticed same call back for all the lines.

Question : EXTi Callback interrupt are served simultaneously if i have multiple EXTI lines firing an int ?
-Affermative :
what can i do to avoid this behave ? ( of course rewriting my code with 1 to 1 relation between EXT line and cb)
-Negative :
Inside my cb i have something like :

Code: Select all

   /** encoder[idx].vtLimit is type  VirtualTimer *   **/
        /** idx is related to the EXTI channel  firing the int **/
chSysLockFromIsr();
   if( chVTIsArmedI(encoder[idx].vtLimit ) ) chVTResetI(encoder[idx].vtLimit );
   chVTSetI(encoder[idx].vtLimit , MS2ST(1000), cbEncoderTimeout , & encoder[idx]  );
chSysUnlockFromIsr();


Why it hangs on chVTSetI ??

Re: EXTI same callback for differents pin

Posted: Thu Feb 21, 2013 3:08 pm
by Debbio
Well,

-i separated the callback functions with a 1 to 1 relation
-i passed ref to VT directly and not through my encoder struct

RESULT : THE SAME ! -> Is not a cb simultaneous execution problem.

In fact when i comment those VT lines of code my system hang before or later in another virtual timer hang or in unhandled exception with no readable backtrace!
example :
chVTSetI hangs on a chThdSleepMillisecond(30) in another thread

IS IT SYSTEM INSTABILTY ? due to what : thread priority , corrupted stack frame ( i have all the debug feature enabled , how to usefull use them ? )

well i'm getting lost scared and confused ..any hints ?

Re: EXTI same callback for differents pin - VT Instability

Posted: Thu Feb 21, 2013 7:11 pm
by Giovanni
Hi,

Hi, callbacks are called separately even if from the same ISR.

I would check for stack overflows. When a debug feature catches something the system is stopped (does not hang) into chSysHalt(), is this the case? you can see that by stopping the program after the system stop. If the system is stopped there is a global pointer pointing to an error message. See the debug unit documentation.

Note that the stack overflow check is not 100% guaranteed, it is performed only on context switch. A better way to assess a stack overflow is to use the Eclipse ChibiOS debug plugin and see if some stack is reported not having any space left. IRQ stack and Process stacks have to be checked visually in the debugger.

Giovanni

Re: EXTI same callback for differents pin - VT Instability

Posted: Thu Feb 21, 2013 8:32 pm
by Debbio
Hi Giovanni,

no the system is not in halt, port disable or similiar

I got 2 hang situations maybe due to the same issue maybe not :

a) System loop in some VT set ( for example after chThreadSleepMilliseconds() ) in chVTSetI( .. ) in :

Code: Select all

  while (p->vt_time < time) {
    time -= p->vt_time;
    p = p->vt_next;
  }


b) System goes to an unhandler exception without any backtrace available.

I tried to eliminate every VirtualTimer i declared in my code and the first stop context disappeared , i m checking for the second one..

About stack overflow i've set every Thread Working area size at least to 256 and then to 512 i'm sure i'm not using all that stack area but i will check it .

Project is complex , it use events ,different threads , EXTI , Virtual Timer , shell( removed temporary ) ..

The strange thing is that i have 2 digital input signal on EXTI at 10 Hz and i noticed i'm unable to serve all input fired ( i miss impulses ) when cpu has some other thing to do..and i' mspeaking about 1 or 2 threads at 40 ms without no such a huge load to justificate the miss.

Situation went better when i set EXTI int priority to 2 but is not sufficient ..

Reassuming ,i'll check thread switching context buffer and i'll try to use chibios plugin.

Re: EXTI same callback for differents pin - VT Instability

Posted: Thu Feb 21, 2013 8:58 pm
by Giovanni
Hi,

A thread stuck in a loop is a symptom of a list corruption and that can happen because stack/arrays overflows. So check stacks and check array indexes.

Also check you don't have ISRs at priorities above kernel, those also can cause list corruptions.

Giovanni

Re: EXTI same callback for differents pin - VT Instability

Posted: Tue Feb 26, 2013 10:24 am
by Debbio
Hi,

after rigorous tests ...i found a terrific and sneaky disturb reentering unlikely in a time window corresponding to the exti signal operation..chip goes mad..resolved the hw issue..disappeared the sw instability!

Thi is the second post i wrote on this forum and this is the second time that is not a chibios or sw fault..next time before posting i will torture hw people in advance :twisted:

Anyway thank you Giovanni for the hint..with test i've learned something more on the OS :)

Re: EXTI same callback for differents pin - VT Instability

Posted: Tue Feb 26, 2013 10:34 am
by Giovanni
Hi,

No problems, it is still experience that becomes available to the forum lurkers.

Giovanni