11 years, 2 months ago.

How to connect to UART0?

Hi,

I am trying to connect to UART0 of the mbed NXP LPC2368 dev kit. According to the schematic, UART0 pins are labeled TGT_SBL_TXD AND TGT_SBL_RXD but I don't see any other connections with these labels. I suspect they may go into the chip on the bottom of the board (the larger device with "mbed interface" written on it) but I can't find any documentation on this. Any help would be appreciated.

Thanks, Kevin VA

Question relating to:

1 Answer

11 years, 2 months ago.

You are right. UART0 is connected to the interface chip. You can use it for printing messages on the PC console (eg Hyperterminal) or sending keystrokes from the PC console. That is, after you have installed a suitable driver on the PC.

It is also possible to send bytes across UART0 and use your own PC software to receive those.

See http://mbed.org/handbook/Serial for more details.

#include "mbed.h"
 
Serial pc(USBTX, USBRX); // tx, rx
 
int main() {
    pc.printf("Hello World!");
    while(1) {
        pc.putc(pc.getc() + 1);
    }
}

It is not easily possible to get access to UART0 pins on the chip for other purposes. When you need a regular serial port, eg to connect to a GPS, then you should use one of the other UARTs. Just declare a Serial object for the correct pins (eg p9, p10).

#include "mbed.h"
#include "GPS.h"
 
Serial pc(USBTX, USBRX);
GPS gps(p9, p10);
 
int main() {
    while(1) {
        if(gps.sample()) {
            pc.printf("I'm at %f, %f\n", gps.longitude, gps.latitude);
        } else {
            pc.printf("Oh Dear! No lock :(\n");
        }
    }
}

Accepted Answer