USB & STMF407 - Why does it stop?

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderators: RoccoMarco, barthess

freakuency
Posts: 4
Joined: Wed Aug 02, 2017 1:09 am

USB & STMF407 - Why does it stop?

Postby freakuency » Wed Aug 02, 2017 3:18 pm

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?

User avatar
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?

Postby Giovanni » Wed Aug 02, 2017 3:31 pm

Hi,

Which OS version are you using? there should be a check in write functions to prevent exactly this.

Giovanni

freakuency
Posts: 4
Joined: Wed Aug 02, 2017 1:09 am

Re: USB & STMF407 - Why does it stop?

Postby freakuency » Wed Aug 02, 2017 4:16 pm

Oh, ofc I left out that important information, it is 16.1.4.

freakuency
Posts: 4
Joined: Wed Aug 02, 2017 1:09 am

Re: USB & STMF407 - Why does it stop?

Postby freakuency » Wed Aug 02, 2017 4:40 pm

Also, a soon as I reconnect the cable again, the system works fine again.

User avatar
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?

Postby Giovanni » Wed Aug 02, 2017 6:16 pm

You should update to the latest version, that one is 2 years old.

Giovanni

freakuency
Posts: 4
Joined: Wed Aug 02, 2017 1:09 am

Re: USB & STMF407 - Why does it stop?

Postby freakuency » Wed Aug 02, 2017 8:48 pm

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");
  }
}


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 15 guests