Skip to content

Latest commit

 

History

History
43 lines (24 loc) · 2.7 KB

Serial.md

File metadata and controls

43 lines (24 loc) · 2.7 KB

Serial

The Serial interface provides UART functionality. The serial link has two unidirection channels, one for sending and one for receiving. The link is asynchronous, and so both ends of the serial link must be configured to use the same settings.

One of the serial connections uses the Arm Mbed USB port, allowing you to easily communicate with your host PC.

Serial class reference

View code

Note: On a Windows machine, you will need to install a USB serial driver. See Windows serial configuration.

Serial channels have a number of configurable parameters:

  • Baud Rate - There are a number of standard baud rates ranging from a few hundred bits per second, to megabits per second. The default setting for a serial connection on the Mbed microcontroller is 9600 baud.
  • Data length - Data transferred can be either 7 or 8 bits long. The default setting for a serial connection on the Mbed microcontroller is 8 bits.
  • Parity - You can add an optional parity bit. The parity bit will be automatically set to make the number of 1s in the data either odd or even. Parity settings are Odd, Even or None. The default setting for a serial connection on the Arm Mbed microcontroller is None.
  • Stop Bits - After data and parity bits have been transmitted, one or two stop bits are inserted to "frame" the data. The default setting for a serial connection on the Mbed microcontroller is one stop bit.

The default settings for the Mbed microcontroller are described as 9600-8-N-1, a common notation for serial port settings.

Serial hello, world

View code

Serial examples

Example one

Write a message to a device at a baud rate of 19200.

View code

Example two

Provide a serial pass-through between the PC and an external UART.

View code

Related content