ClearCore Library
Loading...
Searching...
No Matches
SerialPrint.cpp

Return to SDK Examples for Microchip Studio

1/*
2 * Title: SerialPrint
3 *
4 * Objective:
5 * This example demonstrates how to print text using serial output.
6 *
7 * Description:
8 * This example will print the basic "Hello World" message to the USB serial
9 * port.
10 *
11 * Requirements:
12 * ** None
13 *
14 * Links:
15 * ** ClearCore Documentation: https://teknic-inc.github.io/ClearCore-library/
16 * ** ClearCore Manual: https://www.teknic.com/files/downloads/clearcore_user_manual.pdf
17 *
18 *
19 * Copyright (c) 2020 Teknic Inc. This work is free to use, copy and distribute under the terms of
20 * the standard MIT permissive software license which can be found at https://opensource.org/licenses/MIT
21 */
22
23#include "ClearCore.h"
24
25// ClearCore provides three separate serial interfaces for communications.
26// The three options are ConnectorUsb, ConnectorCOM0, or ConnectorCOM1
27#define SerialPort ConnectorUsb
28
29// Select the baud rate to match the target device.
30#define baudRate 9600
31
32int main() {
33 // Set up serial communication to print.
34 SerialPort.Mode(Connector::USB_CDC);
35 SerialPort.Speed(baudRate);
36 SerialPort.PortOpen();
37 while (!SerialPort) {
38 continue;
39 }
40
41 // The port is open and ready to talk.
42 SerialPort.SendLine("Hello World!");
43}