Page 2 of 2

Re: AVRMega can't switch two threads

Posted: Tue Nov 20, 2012 11:02 am
by birdkung
Now, I detect when program execute function chVTResetI(). After execute that my program will auto reset and run again from start of main function.

Re: AVRMega can't switch two threads

Posted: Tue Nov 20, 2012 12:29 pm
by Giovanni
Without seeing your code it is hard to give meaningful advice. Has the virtual timer been initialized?

Giovanni

Re: AVRMega can't switch two threads

Posted: Tue Nov 20, 2012 2:26 pm
by birdkung
Yes, I initialized virtual timer already.

Code: Select all

msg_t chSchGoSleepTimeoutS(tstate_t newstate, systime_t time) {

  chDbgCheckClassS();

  if (TIME_INFINITE != time) {
    VirtualTimer vt;

    chVTSetI(&vt, time, wakeup, currp);
    chSchGoSleepS(newstate);
    if (chVTIsArmedI(&vt))
      chVTResetI(&vt);
  }
  else
    chSchGoSleepS(newstate);
  return currp->p_u.rdymsg;         << After execute this instruction
}


When my program execute last instruction (return value) of funnction chSchGoSleepTimeoutS(), then my program will exit this function and reset itself.

I try many times for checking it.

Re: AVRMega can't switch two threads

Posted: Tue Nov 20, 2012 2:43 pm
by Giovanni
Does "currp" contain a meaningful value? (it should be pointing to the current thread).

Without more context I can't help.

Giovanni

Re: AVRMega can't switch two threads

Posted: Tue Nov 20, 2012 3:40 pm
by birdkung
Now, I don't have source code. I will send it tomorrow.

Re: AVRMega can't switch two threads

Posted: Wed Nov 21, 2012 2:34 am
by birdkung
https://www.dropbox.com/s/jql248qve6he8xq/test01.rar

Above link is my source code that I use to debugging.