Ok here's a head scratcher...
Teensy 3.2 connected to a computer using onboard USB serial, and FTDI USB to RS232 to a max232 connected to serial1 (pins 0 and 1).
Why doesn't this example code work:
While the version below does work when I removed the #define HWSERIAL Serial1 and explicitly used Serial1 instead of the HWSERIAL????
The version that doesn't work is copied directly from the https://www.pjrc.com/teensy/td_uart.html page. The only part that works is the USB received on the Arduino Monitor.
Is there a different way to define HWSERIAL that will work?
Teensy 3.2 connected to a computer using onboard USB serial, and FTDI USB to RS232 to a max232 connected to serial1 (pins 0 and 1).
Why doesn't this example code work:
Code:
// set this to the hardware serial port you wish to use
#define HWSERIAL Serial1
void setup() {
Serial.begin(9600);
HWSERIAL.begin(9600);
}
void loop() {
int incomingByte;
if (Serial.available() > 0) {
incomingByte = Serial.read();
Serial.print("USB received: ");
Serial.println(incomingByte, DEC);
HWSERIAL.print("USB received:");
HWSERIAL.println(incomingByte, DEC);
}
if (HWSERIAL.available() > 0) {
incomingByte = HWSERIAL.read();
Serial.print("UART received: ");
Serial.println(incomingByte, DEC);
HWSERIAL.print("UART received:");
HWSERIAL.println(incomingByte, DEC);
}
}
While the version below does work when I removed the #define HWSERIAL Serial1 and explicitly used Serial1 instead of the HWSERIAL????
The version that doesn't work is copied directly from the https://www.pjrc.com/teensy/td_uart.html page. The only part that works is the USB received on the Arduino Monitor.
Code:
void setup() {
Serial.begin(9600);
Serial1.begin(9600);
}
void loop() {
int incomingByte;
if (Serial.available() > 0) {
incomingByte = Serial.read();
Serial.print("USB received: ");
Serial.println(incomingByte, DEC);
Serial1.print("USB received:");
Serial1.println(incomingByte, DEC);
}
if (Serial1.available() > 0) {
incomingByte = Serial1.read();
Serial.print("UART received: ");
Serial.println(incomingByte, DEC);
Serial1.print("UART received:");
Serial1.println(incomingByte, DEC);
}
}
Is there a different way to define HWSERIAL that will work?
Last edited by a moderator: