chThdSleepMilliseconds in main possible?

Discussions and support about ChibiOS/NIL, the almost nil RTOS.
Post Reply
wizhippo
Posts: 18
Joined: Thu Oct 31, 2013 3:41 pm

chThdSleepMilliseconds in main possible?

Post by wizhippo »

I'm trying nill out and if I call chThdSleepMilliseconds(250); in main it throws an unhandled excpetion, yet if I move the code into another thread and do not sleep in main I have no issue.

Any ideas?
utzig
Posts: 359
Joined: Sat Jan 07, 2012 6:22 pm
Has thanked: 1 time
Been thanked: 20 times

Re: chThdSleepMilliseconds in main possible?

Post by utzig »

from demos/STM32/NIL-STM32F100-DISCOVERY/main.c

Code: Select all

  /* This is now the idle thread loop, you may perform here a low priority
     task but you must never try to sleep or wait in this loop. Note that
     this tasks runs at the lowest priority level so any instruction added
     here will be executed after all other tasks have been started.*/
  while (true) {
  }


I guess that would also apply to any code you put under main().

Cheers,
Fabio Utzig
wizhippo
Posts: 18
Joined: Thu Oct 31, 2013 3:41 pm

Re: chThdSleepMilliseconds in main possible?

Post by wizhippo »

Didn't see that. Thank you
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: chThdSleepMilliseconds in main possible?

Post by Giovanni »

Correct, no sleeping there.

Giovanni
ulikoehler
Posts: 71
Joined: Tue Mar 17, 2015 2:32 am
Been thanked: 3 times

Re: chThdSleepMilliseconds in main possible?

Post by ulikoehler »

Is there any point in running `__WFI()` in the main() loop for Cortex-Mx?

Best regards,
Uli
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: chThdSleepMilliseconds in main possible?

Post by Giovanni »

Hi,

Yes, placing _WFI in the loop improves power usage, it is not there by default because it can affect some debuggers.

Giovanni
Post Reply