Page 1 of 1
USB & STMF407 - Why does it stop?
Posted: Wed Aug 02, 2017 3:18 pm
by freakuency
My first attempt with ChibiOS is the MEMS example for the disco board. It works and the LEDs changes and I can get the data out to my Qt interface over USB after some changes. Great, but, why does the OS freeze when I unplug the cable? I.e, the LEDs stops. I am calling the send function from the thread that reads with SPI. My guess is a buffer gets full for some reason. I cannot find a way to check IF I can send data before calling the send function, to avoid the freeze. Do you know how to?
Re: USB & STMF407 - Why does it stop?
Posted: Wed Aug 02, 2017 3:31 pm
by Giovanni
Hi,
Which OS version are you using? there should be a check in write functions to prevent exactly this.
Giovanni
Re: USB & STMF407 - Why does it stop?
Posted: Wed Aug 02, 2017 4:16 pm
by freakuency
Oh, ofc I left out that important information, it is 16.1.4.
Re: USB & STMF407 - Why does it stop?
Posted: Wed Aug 02, 2017 4:40 pm
by freakuency
Also, a soon as I reconnect the cable again, the system works fine again.
Re: USB & STMF407 - Why does it stop?
Posted: Wed Aug 02, 2017 6:16 pm
by Giovanni
You should update to the latest version, that one is 2 years old.
Giovanni
Re: USB & STMF407 - Why does it stop?
Posted: Wed Aug 02, 2017 8:48 pm
by freakuency
This is what I did with an example that came with the latest version. The LED still stops. Apparently I am doing something incorrectly. It is not an issue though, as I could just request data from the MCU, and maybe that is the more preferable way to do it. So am just gonna do that and it will be good I guess.
Code: Select all
static THD_FUNCTION(blinker_thread, arg) {
(void)arg;
chRegSetThreadName("blinker");
while (true) {
systime_t time;
time = serusbcfg.usbp->state == USB_ACTIVE ? 250 : 500;
palClearLine(LINE_LED6);
chThdSleepMilliseconds(time);
palSetLine(LINE_LED6);
chThdSleepMilliseconds(time);
chprintf((BaseSequentialStream *)&SDU1, "Test\r\n");
}
}