chThdSleepMilliseconds in main possible?

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

chThdSleepMilliseconds in main possible?

Postby wizhippo » Sun Mar 08, 2015 1:20 am

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: 354
Joined: Sat Jan 07, 2012 6:22 pm
Location: Brazil
Has thanked: 1 time
Been thanked: 16 times
Contact:

Re: chThdSleepMilliseconds in main possible?

Postby utzig » Sun Mar 08, 2015 2:07 am

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: 16
Joined: Thu Oct 31, 2013 3:41 pm

Re: chThdSleepMilliseconds in main possible?

Postby wizhippo » Sun Mar 08, 2015 4:02 am

Didn't see that. Thank you

User avatar
Giovanni
Site Admin
Posts: 11220
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 398 times
Been thanked: 333 times
Contact:

Re: chThdSleepMilliseconds in main possible?

Postby Giovanni » Sun Mar 08, 2015 7:39 am

Correct, no sleeping there.

Giovanni

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

Re: chThdSleepMilliseconds in main possible?

Postby ulikoehler » Wed Jul 29, 2015 9:39 pm

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

Best regards,
Uli

User avatar
Giovanni
Site Admin
Posts: 11220
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 398 times
Been thanked: 333 times
Contact:

Re: chThdSleepMilliseconds in main possible?

Postby Giovanni » Thu Jul 30, 2015 6:28 am

Hi,

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

Giovanni


Return to “ChibiOS/NIL”

Who is online

Users browsing this forum: No registered users and 1 guest