7 years, 5 months ago.

Cannot send packets over USBSerial on KL25Z

I have tried many different drivers and cannot successfully send data from the uC to the computer over USBSerial. I am trying the mbed-official USBSerial driver but have had the same results with the KL25Z fork and the ST micro fork as well as mbed OS2 an OS5. I am able to receive bytes freely from the computer to the uC but I cannot send data the other direction.

I have tried 3 different methods to send data to the computer: _putc(), writeBlock(), and printf(). For all three methods, the first byte is sent back to the computer successfully but then the device gets stuck in an endless while loop on line 863 in USBDevice.cpp. This is the 'Wait for completion' portion of the USBDevice::write() function.

I do not feel that I have enough knowledge about USB interfaces to properly debug this driver.

I have published my test program here.

offending code

#include "mbed.h"
#include "USBSerial.h"
 
//Virtual serial port over USB
USBSerial serial;
DigitalOut thisLED(LED1);
char temp[1];

void receiveSerial()
{
    while (serial.readable())
    {
        temp[0] = serial._getc();
        serial._putc(temp[0]);
        //serial.writeBlock((uint8_t *) temp,1);
        //serial.printf(temp);
    }
}
 
int main(void) {
    serial.attach(&receiveSerial);
    while(1)
    {
      thisLED = !thisLED;
      wait(1);
    }
}

Could possibly be related to: https://github.com/ARMmbed/mbed-os/issues/4761. Then again maybe not :).

posted by Erik - 22 Jul 2017

I have had problems with USBSerial on the DISCO L476 board. I wonder if the issue is related. I have tried a lot of different iterations with mbed 2 and mbed 5 and various builds of USBSerial. I have been using Windows 10. There is a problem somewhere with enumeration of the device in windows (even though windows doesn't report any errors for the device). The issue I am dealing with only occurs on USB 3 ports. I have a computer with USB 2 ports and it works fine there. I have a Nucleo F401 board that works fine with the same USBSerial library on Windows 10 and USB3 port. So some specific combination of micro hardware, micro firmware, pc hardware and windows drivers is causing an error during enumeration.

posted by Graham S. 23 Jul 2017
Be the first to answer this question.