Hi all!
I have always had something like a blinking LED in the while-loop in main, but now it was time to remove this.
So I just have an while(1) loop with nothing in it.
The thing is, when I do this the USB stops working (even if I disable the Idle thread).
So the first question is, why does it stop working?
As the while(1) loop is not a thread it should not congest the USB data pump thread.
Second question, what should you have in the loop to not have this problem?
I can't find any example for this.
Thanks in advance!
Best Regards
Emil
Nothing in idle, blocks USB?
Moderators: RoccoMarco, lbednarz, tfAteba
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: Nothing in idle, blocks USB?
Hi,
The main() function IS a thread with priority NORMALPRIO so it do congest the USB pump thread. This is why all demos have chThdSleep() calls in the main() loop. It is not like the micro has another CPU just for the main.
Giovanni
The main() function IS a thread with priority NORMALPRIO so it do congest the USB pump thread. This is why all demos have chThdSleep() calls in the main() loop. It is not like the micro has another CPU just for the main.
Giovanni
Re: Nothing in idle, blocks USB?
Aha! I must have misunderstood the usage of the main loop.
I had understood that as being the Idle thread, but then it must be running somewhere else (maybe only accessible from the idle hook?).
But thanks for the clarification Giovanni! Now it is perfectly clear.
I had understood that as being the Idle thread, but then it must be running somewhere else (maybe only accessible from the idle hook?).
But thanks for the clarification Giovanni! Now it is perfectly clear.
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: Nothing in idle, blocks USB?
By default it is a normal thread in RT, there is an OPTION to make it the idle thread, in that case the empty loop is OK.
I recommend the default settings.
Giovanni
I recommend the default settings.
Giovanni
Re: Nothing in idle, blocks USB?
Thanks for the clarification!
But what is the default? chconf.h only has:
But what is the default? chconf.h only has:
Code: Select all
/**
* @brief Idle thread automatic spawn suppression.
* @details When this option is activated the function @p chSysInit()
* does not spawn the idle thread. The application @p main()
* function becomes the idle thread and must implement an
* infinite loop. */
#define CH_CFG_NO_IDLE_THREAD FALSE- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: Nothing in idle, blocks USB?
The default is FALSE and means that main() is a normal thread.
Giovanni
Giovanni