USB & STMF407 - Why does it stop?
Moderators: RoccoMarco, barthess
-
- Posts: 4
- Joined: Wed Aug 02, 2017 1:09 am
USB & STMF407 - Why does it stop?
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?
- Giovanni
- Site Admin
- Posts: 14455
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: USB & STMF407 - Why does it stop?
Hi,
Which OS version are you using? there should be a check in write functions to prevent exactly this.
Giovanni
Which OS version are you using? there should be a check in write functions to prevent exactly this.
Giovanni
-
- Posts: 4
- Joined: Wed Aug 02, 2017 1:09 am
-
- Posts: 4
- Joined: Wed Aug 02, 2017 1:09 am
Re: USB & STMF407 - Why does it stop?
Also, a soon as I reconnect the cable again, the system works fine again.
- Giovanni
- Site Admin
- Posts: 14455
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: USB & STMF407 - Why does it stop?
You should update to the latest version, that one is 2 years old.
Giovanni
Giovanni
-
- Posts: 4
- Joined: Wed Aug 02, 2017 1:09 am
Re: USB & STMF407 - Why does it stop?
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");
}
}
Who is online
Users browsing this forum: No registered users and 15 guests