Page 1 of 1

wake up a Thread from an ISR

Posted: Tue Feb 21, 2017 6:30 pm
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

Re: wake up a Thread from an ISR

Posted: Tue Feb 21, 2017 8:04 pm
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

Re: wake up a Thread from an ISR

Posted: Wed Feb 22, 2017 12:13 am
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

Re: wake up a Thread from an ISR

Posted: Wed Feb 22, 2017 9:06 am
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

Re: wake up a Thread from an ISR

Posted: Wed Feb 22, 2017 9:32 am
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);
}

Re: wake up a Thread from an ISR

Posted: Thu Feb 23, 2017 1:17 pm
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