6 years, 11 months ago.

Using D+ and D- pins on an LPC176 as a serial port

Hi, I have a LPC1768 that has a microUSB connector on board. I have build a system where a PC can interact to the MBED using the serial port via the microUSB connector. Now I'm making an enclosed case for the machine where the MBED will be hidden inside the machine. In my front my panel I have attached a USB Type-B connector and I want to hook it up to the MBED to act as a serial port. I tried doing this by attaching the D+ and D- pins of the USBtype B connector to the D+ and D- pins on the MBED and a common ground with an external power source connected to VIN and it didnt work. How can I make this work?

PS: All the digitals pins has already been used up henced cant use the serials ports from there. Any help will be much appreciated, Thank you!

Actually, if you want to use the additional pins of the mbed LPC1768 for USB Virtual COM Port via the interface-chip on the mbed board, you have to use the IF+ and IF- for that and not the D+ and D- pins. The D+ and D- pins are connected directly to the hardware USB peripheral in the LPC1768 chip. You can use these too of course, but only with the additional USBserial library to have it enumerate correctly as VCOM interface. If you want to use the standard way via the interface chip with only the standard Serial class (Serial pc(USBTX, USBRX)) you will have to extend either the microUSB connector or use the IF-pins as stated above.

Kind regards

posted by Nenad Milosevic 01 Jan 2017

1 Answer

6 years, 11 months ago.

You should also connect the 5V from the USB B connector to the microUSB. This is needed for the mbed interface to detect the presence of a USB cable.

Okay this how I connected it USB Type B MBED Vcc > VIn D+ > D+ D- > D- GND > GND

I tried this and the Power LED on the LPC1768 light up but my PC did not detect a COM port of any sort. I even tried adding a pull down resistor to the D+ and D- pins and it didnt work

posted by Khayhen Sarveswarah 30 Dec 2016

As stated above: connect the USB B Vcc to the Vcc pin of the microUSB Connector on mbed. The USB B cable to the microUSB connector should just be an extension cord. The Vin pin is ONLY for an external powersupply, but does not mean that the USB connection to the PC is recognised. With the proper cable installed the PC should now detect a new USB memory device. Note that the comm port will only show up after installing the serial port driver. This needs to be done once for every new PC and will only succeed when an mbed is present.

posted by Wim Huiskamp 30 Dec 2016

Yes I have already installed the serial port driver. However, I'm not looking to make an extension cable to the microUSB connector. I'm using a female USB B connector like this http://i.ebayimg.com/images/g/h1AAAOxyYSJSAbOM/s-l300.jpg and I want to connect this to the pins of the MBED not the microUSB connector.

posted by Khayhen Sarveswarah 31 Dec 2016

EDIT: An extension cable between the microUSB socket on the mbed and a USB B socket is really the easiest solution since you need to connect the Vcc pin of the microUSB socket. Do a test to verify this works. Hacking a microUSB cable is the easiest way to make a cable with a microUSB plug on one end and a USB B socket on the other. If you really want to use the IF+,IF-,GND,Vin instead of the microUSB socket on the mbed you will have to solder some flying wire between Vin and the Vcc pin on the mbed microUSB socket to make that work (this is also explained in the link you refer to below).

The D+ and D- pin are used only when the target LPC1768 is to act as standalone USB device (ie without using the mbed interface/programming part). The lpc1768 can indeed behave as USB serial device when executing the mbed USBSerial lib code and with the correct PC driversoftware. Hacking a USB cable is again the easiest way to make a hardwired connection between a USB A plug and D+,D-, GND, Vin (so now the mbed looks similar to a PC USB mouse). The solution with a USB B socket on the mbed side is another option (looks similar to a Printer).

posted by Wim Huiskamp 31 Dec 2016

Oh I see. Can I take an old microUSB - USB type A cable snip off the USB type A connector and solder the wires to the female connector that I have? And just out of curiosity what are the D+ and D- pins for if you can't use it to connect to an external connector? Plus I found this https://developer.mbed.org/users/suupen/notebook/how-to-external-usb-receptacle-on-mbed/ but I don't understand it

posted by Khayhen Sarveswarah 31 Dec 2016