Return to SDK Examples for Microchip Studio
#include "ClearCore.h"
#define baudRateSerialPort 115200
#define baudRateInputPort 115200
#define isTtlInputPort false
#define SerialPort ConnectorUsb
#define InputPort ConnectorCOM0
int16_t input;
int main() {
SerialPort.Mode(Connector::USB_CDC);
SerialPort.Speed(baudRateSerialPort);
SerialPort.PortOpen();
while (!SerialPort) {
continue;
}
if (isTtlInputPort) {
InputPort.Mode(Connector::TTL);
}
else {
InputPort.Mode(Connector::RS232);
}
InputPort.Speed(baudRateInputPort);
InputPort.PortOpen();
while (!InputPort) {
continue;
}
while (true) {
input = InputPort.CharGet();
if (input != -1) {
SerialPort.Send("Received: ");
SerialPort.SendLine((char)input);
}
else {
SerialPort.SendLine("No data received...");
}
}
}
void Delay_ms(uint32_t ms)
Blocks operations for ms milliseconds.
Definition SysTiming.h:287