Maple Reference Documentation: USART

Hardware/Circuit Design

The Maple has 3 seperate USART devices: Serial1, Serial2, and Serial3. In the most simple use case the RX and TX pins are used to send data at a predetermined baudrate with the the line voltage level relative to ground.
Port Function Pin
Serial1 TX D7
Serial1 RX D8
Serial1 CK D6
Serial2 TX D1
Serial2 RX D0
Serial2 CK D10
Serial2 CTS D2
Serial2 RTS D3
Serial3 TX D29
Serial3 RX D30
Serial3 CK D31
Serial3 CTS D32
Serial3 RTS D33

Compatible Devices and Specifications

We have successfully used the Maple USART ports with an FT232R-based USB-serial converter at up to 115200 baud; higher speeds should certainly be possible.

Function Reference

In the following replace "SerialN" with Serial1, Serial2, or Serial3.
SerialN.begin(baudrate)
begin() is usually called in setup() to configure the baudrate of the given serial port and to set up the header pins appropriately. It can be called at any time to reconfigure a port or to change the baudrate. 9600 baud is the generic speed most widely supported by other devices and terminals.
SerialN.print(...)
SerialN.println(...)
Writes data into the port buffer to be transmitted as soon as possible. Accepts strings (character arrays). If a raw integer is passed the corresponding ASCII character will be transmitted; to print out a number in human readable form add a second parameter with the base system. Eg, to print out the decimal number '1234' use print(1234,DEC); to print out the binary numner '1001' use print(9,BIN).
SerialN.available()
SerialN.read()
read() will return any data that has been recieved over the port and available() will tell if any such data acutally exists, and if so how many bytes. If there is no data read() will block/fail, so the usual program structure is to poll with available() and only read() if there's something ready.

Recommended Reading

About this Document

A more recent version of this document may be available from the LeafLabs website. Our documentation is versioned on github; you can track changes to the master branch at this link.

Creative Commons License
This documentation is released under a Creative Commons Attribution-Share Alike 3.0 license.

Translations are welcomed; give us a ping to make sure we aren't in the process of revising or editing first.