Page 2 of 2
Re: usb shell spawn
Posted: Fri Jul 25, 2014 9:24 pm
by jscott
I doubt it is a chibios problem.
Where is your main where you init chibios?
Can you provide your whole file? If not, can you create a short test program that does the
same thing?
Are you running a debugger? can you see what the processor is doing? Do you have all the debug
options turned on?
You might want to add a blinking LED thread. It is amazing how much you can tell just by how
a simple LED blinks.
Check the demo programs. There are one or two around that use the usb port shell.
-John Scott
Re: usb shell spawn
Posted: Fri Jul 25, 2014 9:33 pm
by Giovanni
That while(true){} blocks the execution of all threads at lower priority, including the USB thread.
Giovanni
Re: usb shell spawn
Posted: Fri Jul 25, 2014 9:34 pm
by Pask
if I add palSetPad (GPIOD, GPIOD_LED6) to the body of the thread, the LED lights up. I found that the thread is running. The problem is that the condition SDU1.config-> USBP-> state == USB_ACTIVE is not checked in the thread unlike what happens if the code is not in the thread
Re: usb shell spawn
Posted: Fri Jul 25, 2014 9:37 pm
by Pask
Giovanni wrote:That while(true){} blocks the execution of all threads at lower priority, including the USB thread.
Giovanni
oh no it is so misleading documentation. I do some testing and will update
how can I not block all threads?
Re: usb shell spawn
Posted: Fri Jul 25, 2014 9:39 pm
by jscott
Ah! Yes.
In your main change
to
Code: Select all
while(TRUE)
{
chThdSleepMilliseconds(500);
}
Never use an empty loop in an RTOS... I know from experience.
If you have other code that runs in that while() loop, you will probably want to use
a shorter delay. A few milliseconds would be fine. An empty loop does not need
to run often to get its work done!
-John Scott
Re: usb shell spawn
Posted: Fri Jul 25, 2014 9:45 pm
by Pask
Re: usb shell spawn
Posted: Fri Jul 25, 2014 9:47 pm
by jscott
welcome to the school of hard knocks...
Is it working now?
If not, give us an update when you can.
-John Scott
Re: usb shell spawn
Posted: Fri Jul 25, 2014 9:49 pm
by Pask
I have another question: if the application crashes and unhandled_Exception function is called, all running threads are blocked or only the thread that caused the crash?
Re: usb shell spawn
Posted: Fri Jul 25, 2014 9:50 pm
by Pask
jscott wrote:welcome to the school of hard knocks...
Is it working now?
If not, give us an update when you can.
-John Scott
working working...
Re: usb shell spawn
Posted: Mon Jul 28, 2014 3:09 am
by jscott
Pask wrote:I have another question: if the application crashes and unhandled_Exception function is called, all running threads are blocked or only the thread that caused the crash?
It does what is basically a no-no in an RTOS. However, this time it is just what you want
to happen. Full screaming halt. You NEVER want an unhandled exception to slip by unnoticed.
-John
Code: Select all
00216 /**
00217 * @brief Unhandled exceptions handler.
00218 * @details Any undefined exception vector points to this function by default.
00219 * This function simply stops the system into an infinite loop.
00220 *
00221 * @notapi
00222 */
00223 #if !defined(__DOXYGEN__)
00224 __attribute__ ((naked))
00225 #endif
00226 void _unhandled_exception(void) {
00227
00228 while (TRUE)
00229 ;
00230 }