USB stalls after reconnecting

IDE: 1.8.7
OS: Win10 Pro 64 US

My Zero stalls when physically disconnecting and then reconnecting to the USB from a terminal program. Am I the only one seeing this? Am I doing something wrong?

Here is a more detailed description and sample code.

  • My code is running on the Zero that is supplied from an external power supply.
  • The USB is connected to my PC running either the IDE or a stand alone terminal program (Termite).
  • I then disconnect the USB.
  • I then reconnect the USB and fire up the terminal program again.
  • The Zero continues to send the increasing counter value to the terminal program.
  • If I then send some data to the Zero noting happens.
  • After sending something to the Zero twice the terminal program stalls.
    The odd thing is that if I don't send anything to the Zero the increasing counter value will continue to be received by the terminal program. But sending data form the terminal program to the Zero is a problem.

I want to run my Zero on external power, to do various tasks, and from time to time connect a PC to it to make some management. Doing the same on a Nano is not a problem.

int i = 0;

void yield()
{
    if (SerialUSB.available())
    {
        char ch = (char) SerialUSB.read();
        SerialUSB.print(ch);

        if (ch == '\n')
            SerialUSB.println("Wow, I am really excited you wrote that");
    }
}

void setup()
{
    SerialUSB.begin(9600);
    delay(2000);

    SerialUSB.println("USB test ready");
}

void loop()
{
    SerialUSB.println(i++);
    delay(500);
}

When the problem shows it is not a problem reprogramming the Zero. :confused:

TIA

Hi MikD,

look at this issue on GitHub:

Marco

Ciao Marco

Fix worked here too :slight_smile:

When will it be included in the general SAMD M0 package? 1.6.19 installed here prior to applying the fix and it did not work.

Thanks!

Hi MikD,

When will it be included in the general SAMD M0 package? 1.6.19 installed here prior to applying the fix and it did not work.

.

The USB bug has been fixed but the current revision, 1.6.19, is buggy and I don’t know when a new SAMD M0 package will be released.

May be that cmaglie can answer this question ? ::slight_smile:

Marco

Hi MikD,

the USB issue has been fixed in the 1.6.20 core release, now available.

Ciao
Marco