Rennie Johnson
Member
This subject has been covered in prior years, but I'm not clear on the solution. Please forgive the redundancy.
I have a circuit board controlled by a Teensy 4.1, and a daughter card with Teensy 4.0. I need them to talk to each other. I have connected the Serial1 ports and RTS/CTS pins per the PJRC website reference as follows:
TEENSY 4.1 (CLIENT) TEENSY 4.0 (SERVER)
00 (TX)---------------------01 (RX)
01 (RX)---------------------00 (TX)
32 (CTS-XBAR)------------17 (RTS)
27 (RTS)--------------------02 (CTS-XBAR)
Serial communication works in both directions without flow control, but fails when flow control is enabled.
Here are the test sketches:
Teensy 4.1 (CLIENT):
Here is the sketch for the Teensy 4.0 (SERVER)
With the hardware flow control disabled, the sketch works correctly:
When hardware control is enabled, there is no communication:
Have I wired incorrectly, or not invoked hardware control in the proper code sequence? There is a discussion of this issue on the forum late last year, but it's a little over my head and I'm not clear what the recommended solution is. The PJRC reference calls attention to the CTS inversion, but it doesn't indicate you can't make hardware flow control work.
https://forum.pjrc.com/index.php?threads/teensy-4-1-and-attachcts.74141/
Would it help to put a inverting buffer on the CTS outputs? Would that cause a timing problem?
Thanks for your guidance.
I have a circuit board controlled by a Teensy 4.1, and a daughter card with Teensy 4.0. I need them to talk to each other. I have connected the Serial1 ports and RTS/CTS pins per the PJRC website reference as follows:
TEENSY 4.1 (CLIENT) TEENSY 4.0 (SERVER)
00 (TX)---------------------01 (RX)
01 (RX)---------------------00 (TX)
32 (CTS-XBAR)------------17 (RTS)
27 (RTS)--------------------02 (CTS-XBAR)
Serial communication works in both directions without flow control, but fails when flow control is enabled.
Here are the test sketches:
Teensy 4.1 (CLIENT):
Code:
void setup() {
Serial.begin(9600);
Serial1.begin(9600);
// Serial1.attachRts(27);
// Serial1.attachCts(32);
delay(10);
Serial1.clear();
delay(1000);
}
void loop() {
byte inByte;
byte x;
Serial1.clear();
for(x=0;x<255;x++)
{
delay(1000);
Serial.print("Sending: ");
Serial.print(x);
Serial.println("");
Serial1.write(x);
delay(20);
if(Serial1.available()>0)
{
inByte = Serial1.read();
Serial.print("Received: ");
Serial.print(inByte);
Serial.println("");
Serial.println("");
}
else
{
Serial.println("No Incoming Bytes Available.");
Serial.println("");
}
}
}
Here is the sketch for the Teensy 4.0 (SERVER)
Code:
void setup() {
Serial1.begin(9600);
// Serial1.attachRts(17);
// Serial1.attachCts(2);
delay(1);
Serial1.clear();
}
void loop() {
byte inByte;
if(Serial1.available()>0)
{
inByte = Serial1.read();
Serial1.write(inByte);
}
}
With the hardware flow control disabled, the sketch works correctly:
When hardware control is enabled, there is no communication:
Have I wired incorrectly, or not invoked hardware control in the proper code sequence? There is a discussion of this issue on the forum late last year, but it's a little over my head and I'm not clear what the recommended solution is. The PJRC reference calls attention to the CTS inversion, but it doesn't indicate you can't make hardware flow control work.
https://forum.pjrc.com/index.php?threads/teensy-4-1-and-attachcts.74141/
Would it help to put a inverting buffer on the CTS outputs? Would that cause a timing problem?
Thanks for your guidance.