10 years, 5 months ago.

Problem with USBSerial class

I need to communicate a PC with other device, this device has an UART port and the communication occurs in raw mode at 115200 bps - 8N1. I'm using a mbed (LPC1768) board acting as a bridge between the PC and the device. When I connect the USB connector of the mbed board and implement below code, it works perfectly:

#include "mbed.h"
 
Serial      pc(USBTX, USBRX); // tx, rx
Serial      RS500(p13, p14);  // tx, rx

int main() {

    RS500.baud(115200);

    while(1) {
        if (pc.readable()) RS500.putc(pc.getc());
        if (RS500.readable()) pc.putc(RS500.getc());
    }
}

The problem occurs when I use the USBSerial class, I have implemented the hardware for the D+ & D- signals and the code below, but with this class the communication stops after few moments. Anyone has a suggestion?

#include "mbed.h"
#include "USBSerial.h"
 
USBSerial      pc;
Serial             RS500(p13, p14);  // tx, rx

int main() {

    RS500.baud(115200);
            
    while(1) {
        if (pc.readable()) RS500.putc(pc.getc());
        if (RS500.readable()) pc.putc(RS500.getc());
    }
}

Someone has a suggestion? I'm working with the latest versions of the libraries. Thanks and Regards

posted by Samuel Ramirez 02 Jul 2014
Be the first to answer this question.