UART in ARM MBED LPC1768

UART (Universal Asynchronous Receiver/Transmitter) is a serial communication protocol in which data is transferred serially bit by bit at a time. Asynchronous serial communication is widely used for byte oriented transmission. In Asynchronous serial communication, a byte of data is transferred at a time.

MBED has three UART interfaces. The ESP8266 data transfer speed via UART interfaces can reach 40 times of 115200 i.e. 4.5 Mbps. By default, UART0 baud rate is 115200 for the oscillator of 40MHz. It can be changed to user defined value according to need of application.

UART Pins in ARM MBED Board

Fig. UART Pins of MBED Board

 

UART Functions for MBED LPC1768

Serial (PinName tx, PinName rx, const char *name=NULL, int baud=MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE)

Create a Serial Object first connected to the specified serial pin.

tx         Transmit pin

rx         Receive pin

name   The name of the stream associated with this serial port (optional)

baud    The baud rate of the serial port (optional, defaults to MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE)

 

Serial (PinName tx, PinName rx, int baud)

Create a serial Object first connected to the specified serial pin.

tx         Transmit pin

rx         Receive pin

baud    The baud rate of the serial port (optional)

e.g.

Serial pc(p9, p10);

 

Interfacing Diagram

Fig: MBED UART Interfacing Diagram with Arduino Uno

 

Program

Arm MBED Serial UART Program: 

#include "mbed.h"

Serial pc(p9, p10); // tx, rx

int main() {
    pc.baud(9600);	// set baud rate 9600
    while(1) {
	pc.printf("Hello Arduino!\n\r");	// send data serially
	wait(1);	// wait for 1 second 
    }
}

 

Arduino Serial UART Program: 

void setup() {
  Serial.begin(9600); // set baud rate to 9600
}

void loop() {
  while (Serial.available()) {
  char data = Serial.read();  // read serially data
  Serial.print(data); // print serially data on serial monitor
  }
}

 

Output Window


Components Used

ARM mbed 1768 LPC1768 Board
ARM mbed 1768 Board
1
Arduino UNO
Arduino UNO
1
Ad