Simple SerialBridge not working on LPC11U24 ?

24 Jan 2012

Hi,

This simple code works fine on the LPC1768, but not on the new LPC11U24. Have I missed something?

#include "mbed.h"

Serial pc(USBTX, USBRX); // tx, rx
Serial device(p9, p10);  // tx, rx
DigitalOut rxLed(LED1);
DigitalOut txLed(LED2);

int main() {
    while(1) {
        if(pc.readable()) {
            device.putc(pc.getc());
            txLed =! txLed;
        }
        if(device.readable()) {
            pc.putc(device.getc());
            rxLed =! rxLed;
        }
    }
}
25 Jan 2012

Stupid question, but have you selected LPC11U24 from compiler drop down box ? This catches me out every time I switch back & fourt

Also, you have not set the baud rate, Don't think this matters too much, Should default to 9K6.

Hope this helps Ceri

25 Jan 2012

Thanks,

Yes selected correct platform for compiler. Tried forcing baud to 9600 but makes no difference. Also made sure to update mbed lib.

Thanks, Serge

25 Jan 2012

The LPC11U24 has only one UART, which is physically connected to both, the MBED-chip (being the PC-USB-to-serial transceiver) and the MBED-pins p9 and p10. So in your code "pc" and "device" are actually two pointer instances to the same hardware peripheral and you are implementing some kind of echo loop this way, which of course doesn't work.

Best regards Neni

25 Jan 2012

Bummer.

Thanks, Serge

25 Jan 2012

You could use the USBSerial (http://mbed.org/handbook/USBSerial) to communicate with the host pc and use p9,p10 as regular UART. Alternatively, do a software UART (bitbanging DigitalOut pin) or add external hardware like a SPI-to-Serial interface.

25 Jan 2012

Hi,

Yes no worries but this is not exactly "compatible" with the LPC1768 so thats why I was a little surprised that everything compiled fine but simply did not work. Some form of warning or the renaming of the pins from USBTX and USBRX to something else might have been useful to avoid confusion.

Serge