Teensy 4.1 to Uno communication

I have an audio recorder working well on the Teensy. I have a 5” TFT working well on the Uno using I2C comms. The libraries supplied with the TFT will not work with the Teensy (LiquidCrystalDisplay.h), so I want to use the Uno to control the Teensy audio recorder via Rx/Tx comms. Both MCUs are set to 38400 baud and Tx connects to Rx and v.v.

Both MCUs connect to the programming IDE with the serial monitor and send and receive data to them no problem but won’t apparently send to each other

Much reduced code from Uno to Teensy

Serial.begin(38400);

if (Serial.available() > 0) {         // this should work alongside buttons
    // read the incoming byte:
    incomingByte = Serial.read();
    // Respond to button presses
    if ( incomingByte == '1' ) {
      Serial.println("Record Button Press");
      if (mode == 2) stopPlaying();
      HeaderNotWrittenYet = true;
      if (mode == 0) startRecording();
      AboutToDelete = false;
    }
    if ( incomingByte == '2' ) {
      Serial.println("Stop Button Press");
      if (mode == 1) stopRecording();
      if (mode == 2) stopPlaying();
      mode = 0;
      AboutToDelete = false;
    }
}

But nothing happens! If I send a ‘1’ from the IDE serial monitor the Teensy responds with “Record Button pressed” correctly. If I press a hardware button on the audio recorder, the Teensy sends a file list back to the IDE serial monitor. Same problem in the other direction where I want to display a file list on the Uno TFT.

BTW I have disconnected the USB when trying to get the MCUs to talk to each other.

The other solution to this problem might be to get a Teensy 4.1 compiler friendly library for the H50B-IC. I can’t find one.

Any suggestions gratefully received.

Which Uno? One reason I am asking is many Unos run with 5v signals and the Teensy 4.1 runs with Signals at 3.3v and the IO pins are not 5v tolerant.

Where does mode get set other than if '2' it gets set to 0...

mode is just my way of deciding whether I’m in recording, playback or doing nothing state. It is very obvious via the user interface what is going on (or in this case), not going on.

Why is it both IDEs communicate perfectly via USB, also at 38400 baud, but one MCU won’t talk to the other? In the IDEs I use character plus ENTER to send a command, that’s why I used Serial.println(whatever) to get the two MCUs to talk to each other. Was that the mistake?

The Uno is R3.

Apart from connecting the Tx and Rx pins crossover between, I also tried (seperately) to try an crossover USB cable with USB 1 at one end and micro at the other but that didn’t work either.

You probably would have a better chance asking about this on the PJRC (Teensy forum)
Teensy Forum

Might help if you had a link to the display you are using...
Looking at that chip, it looks like it is a 5v chip Voltage > 4.5v and I have not checked to
see what if any of the pins go > 5v or only input, where HIGH needs to be at least 2.2v...
So maybe can be run from Teensy 3.3v ...

I am pretty sure most R3s run with 5v on the IO pins. Could be wrong as I don't have one... Have older ones. 5v can damage a Teensy 4.x

I was just mentioning about mode as:

if ( incomingByte == '2' ) {
      Serial.println("Stop Button Press");
      if (mode == 1) stopRecording();
      if (mode == 2) stopPlaying();
      mode = 0;
      AboutToDelete = false;
    }

for example in your code fragment mode will never not be 0...

Which pins did you use on the T4.1? Pin0 is RX1 and pin2 is TX1. These are accessed using Serial1 (not Serial).

For the T4.1, your code should use

Serial1.begin(38400);

if (Serial1.available() > 0) {         // this should work alongside buttons
    // read the incoming byte:
    incomingByte = Serial1.read();

Pete

P.S. BUT note what KurtE said about the fact that the T4.1 pins are 3.3V and are NOT 5V tolerant.

Now that is strange. Last time I tried to compile with Serial1 it threw out errors but this time it compiled OK? Weird! Late at night. Will update tomorrow. So if I use Serial1 to communicate with the UNO will it still use Serial to USB back to the IDE?

You will most assuredly have an easier time getting a TFT to work with the Teensy then you will coordinating serial comms between two processors. The latter will be significantly more complex. Besides the logic level concerns already raised, you will have issues of creating a proper serial protocol that will handle framing, synchronization, etc.

Teensys have an advantage that any of the extra Serial ports (Serial1, Serial2, etc) can be used at the same time as the USB Serial port (Serial) is in use.
I haven't used UNO or NANO for years but I seem to remember that you can only use either Serial USB OR the Serial port on pins 0 and 1, which makes them a pain to use.

Maybe you had "Serial1" in your UNO code or you compiled the T4.1 code for the UNO. That would cause errors.

Pete

Thankyou gentlemen. Using Serial1 to receive commands to the T 4.1 from the UNO now works and the T 4.1 sends correct responses back to the IDE serial monitor on the USB. So now I’m half way to getting something working. I’ve also posted on the Teensy forum to see if someone has a link to Teensy libraries for the H50B which will compile on the T 4.1.

Thanks for your help!