wake up a Thread from an ISR

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

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
cheater
Posts: 3
Joined: Tue Feb 21, 2017 6:16 pm

wake up a Thread from an ISR

Post by cheater »

Hi, ich have a problem waking up my thread from isr. i implemented it like mentioned here for async wakeup http://www.chibios.org/dokuwiki/doku.php?id=chibios:howtos:wakeup

Code: Select all

static WORKING_AREA(blinkLeftThreadWorkingArea, 1024);
static msg_t blinkLeftThread(void *param) {
  blinkerLeftThread = chThdSelf();
  chEvtWaitAny((eventmask_t)1);
  //some code doing stuff
  return;   
}


void startBlinkerLeft(){
  blinkThreadLeft=true;
  chThdCreateStatic(blinkLeftThreadWorkingArea, sizeof(blinkLeftThreadWorkingArea), HIGHPRIO, blinkLeftThread, (void *)&blinkThreadLeft);
}

static void toggleBlinkerLeft(EXTDriver *extp, expchannel_t channel){
  CH_IRQ_PROLOGUE();
  chSysLockFromIsr();
  chEvtSignal(blinkerLeftThread, (eventmask_t)1);
  chSysUnlockFromIsr();
  CH_IRQ_EPILOGUE();
}

int main(void)
{
     startBlinkerLeft();
     //chEvtSignal(blinkerLeftThread, (eventmask_t)1);
}


it simply does nothing, and the interrupt works if i put code in it to flash an LED.
if i commend out the 2nd line in the main the thread wakes up.
im currently working with the old chibios 2.6

please help me, its very urgent

kind regards
cheater
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: wake up a Thread from an ISR

Post by Giovanni »

Hi,

You must use chEvtSignalI() from ISR context.

Not sure if it is your only problem, enabling state checker and assertions in chconf.h would have caught that.

Giovanni
cheater
Posts: 3
Joined: Tue Feb 21, 2017 6:16 pm

Re: wake up a Thread from an ISR

Post by cheater »

Hi Giovanni, thx for your very fast reply!
i tried it also with chEvtSignalI(), but it results in the same behaviour.
What should i do after enabling state checker and assertions in chconf.h?
assertion on true freezes everthing
state checker one true freezes when entering the isr


kind regards
cheater
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: wake up a Thread from an ISR

Post by Giovanni »

Hi,

Assertions are meant to halt the system, it means that an error is found, please read this article for details: http://chibios.org/dokuwiki/doku.php?id ... ebug_guide

Giovanni
steved
Posts: 834
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 138 times

Re: wake up a Thread from an ISR

Post by steved »

If you want to trigger your thread more than once, the code needs to be in a loop.

thread_t blinkerLeftThread;

Code: Select all

static WORKING_AREA(blinkLeftThreadWorkingArea, 1024);
static msg_t blinkLeftThread(void *param) {
  while (1)
  {
    chEvtWaitAny((eventmask_t)1);
    //some code doing stuff
  }
}


void startBlinkerLeft(){
  blinkThreadLeft=true;
  blinkerLeftThread = chThdCreateStatic(blinkLeftThreadWorkingArea, sizeof(blinkLeftThreadWorkingArea), HIGHPRIO, blinkLeftThread, (void *)&blinkThreadLeft);
}

static void toggleBlinkerLeft(EXTDriver *extp, expchannel_t channel){
  CH_IRQ_PROLOGUE();
  chSysLockFromIsr();
  chEvtSignalI(blinkerLeftThread, (eventmask_t)1);
  chSysUnlockFromIsr();
  CH_IRQ_EPILOGUE();
}

int main(void)
{
     startBlinkerLeft();
     //chEvtSignal(blinkerLeftThread, (eventmask_t)1);
}
cheater
Posts: 3
Joined: Tue Feb 21, 2017 6:16 pm

Re: wake up a Thread from an ISR

Post by cheater »

chibistudio looks like the following now
[url]
http://imgur.com/a/vrGHH[/url]

the debug view is completely empty
http://www.directupload.net/file/d/4641 ... pt_png.htm

what should i do? how can i read these messages? where should i click?

kind regards
cheater
Post Reply