AVRMega can't switch two threads

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

Moderators: utzig, tfAteba

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

Re: AVRMega can't switch two threads

Postby birdkung » Tue Nov 20, 2012 11:02 am

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: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: AVRMega can't switch two threads

Postby Giovanni » Tue Nov 20, 2012 12:29 pm

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

Postby birdkung » Tue Nov 20, 2012 2:26 pm

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: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: AVRMega can't switch two threads

Postby Giovanni » Tue Nov 20, 2012 2:43 pm

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

Postby birdkung » Tue Nov 20, 2012 3:40 pm

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

Postby birdkung » Wed Nov 21, 2012 2:34 am

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

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


Return to “AVR Support”

Who is online

Users browsing this forum: No registered users and 8 guests