UART Test using example code.

Status
Not open for further replies.

swpmx

Member
Does the example teensy "EchoBoth" sketch require any external hardware for this line to become true for Teensy 3.2:

if (HWSERIAL.available() > 0) {

This line is never true when I run the sketch when nothing is connected to pins 0 (RX) and 1 (TX).

#define HWSERIAL Serial1

void setup() {
Serial.begin(9600);
HWSERIAL.begin(38400);
}

void loop() {
int incomingByte;

if (Serial.available() > 0) { /// <----- This line works fine and is true when data is entered
incomingByte = Serial.read();
Serial.print("USB received: ");
Serial.println(incomingByte, DEC);
HWSERIAL.print("USB received:");
HWSERIAL.println(incomingByte, DEC);
}
if (HWSERIAL.available() > 0) { /// <------This line is never true.
incomingByte = HWSERIAL.read();
Serial.print("UART received: ");
Serial.println(incomingByte, DEC);
HWSERIAL.print("UART received:");
HWSERIAL.println(incomingByte, DEC);
}
}
 
Last edited:
Only the USB cable is plugged into the Teensy 3.2 all other pins are not connected.

What is required for (HWSERIAL.available() >0) to be true (greater than 0)?
 
...

What is required for (HWSERIAL.available() >0) to be true (greater than 0)?
expected: Serial device (including, certainly not limited to, another Teensy) connected to the appropriate pins on Teensy AND transmitting appropriately.
 
Only the USB cable is plugged into the Teensy 3.2 all other pins are not connected.

What is required for (HWSERIAL.available() >0) to be true (greater than 0)?
Quick read.... I'd say that something needs to send data to the RX pin.
A "loop-back" test would be to connect the TX pin to the RX pin. Then send a character to the hardware serial port and see if receive it.
 
Quick read.... I'd say that something needs to send data to the RX pin.
A "loop-back" test would be to connect the TX pin to the RX pin. Then send a character to the hardware serial port and see if receive it.

OK, thanks. That is what I wanted to know. It does require connections to RX pin before the Serial.available will be true then.


Thanks for the responses.
 
Status
Not open for further replies.
Back
Top