AVRMega can't switch two threads

ChibiOS public support forum for topics related to the Atmel AVR family of micro-controllers.

Moderator: tfAteba

birdkung
Posts: 9
Joined: Fri Nov 16, 2012 8:38 am

Re: AVRMega can't switch two threads

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

Re: AVRMega can't switch two threads

Post by Giovanni »

Without seeing your code it is hard to give meaningful advice. Has the virtual timer been initialized?

Giovanni
birdkung
Posts: 9
Joined: Fri Nov 16, 2012 8:38 am

Re: AVRMega can't switch two threads

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

Re: AVRMega can't switch two threads

Post by Giovanni »

Does "currp" contain a meaningful value? (it should be pointing to the current thread).

Without more context I can't help.

Giovanni
birdkung
Posts: 9
Joined: Fri Nov 16, 2012 8:38 am

Re: AVRMega can't switch two threads

Post by birdkung »

Now, I don't have source code. I will send it tomorrow.
birdkung
Posts: 9
Joined: Fri Nov 16, 2012 8:38 am

Re: AVRMega can't switch two threads

Post by birdkung »

https://www.dropbox.com/s/jql248qve6he8xq/test01.rar

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