I have a few questions about the communications with the Mega and a Touchshield (TSS).
The Mega communicates with the USB port (PC) using pins 2 and 3. 2 is the RX and 3 is the TX. However, the TSS uses these same two pins and are connected to the same pins 2 and 3 using the same pinout. This would seem to have two outputs (TX) from two devices, driving the same line at the same time (albeit there is a 1K resistor between).
Also, I have notice that I cannot load programs, into the Mega, unless I remove the TSS first. There is a conflict when both are connected at the same time.
Question1:
Can these two TX pins both connected at the same time, cause damage to the chips? This doesn't look like good design practice but the TSS is supposed to be compatible with this board.
Question 2:
In order to communicate with the TSS, from the Mega, using the SoftwareSerial is necessary and the pin function is reversed on the Mega. But if I reverse the TX/RX pin functions, that would seem to make the hardware serial non-functional. However it isn't.
I have written a program that will communicate over USB and to the TSS, both using these same 2 pins. But in the code there is only one setup for pin direction. How is it that this can send both hardware serial using pin2=Rx, pin3=Tx and SoftwareSerial using pin2=Tx, pin3=Rx?
#include <SoftwareSerial.h>
#include "Wire.h"
#include <LibTemperature.h>
#define RX_PIN 3
#define TX_PIN 2
LibTemperature temp = LibTemperature(0);
SoftwareSerial mySerial = SoftwareSerial(RX_PIN, TX_PIN);
void setup()
{
pinMode(RX_PIN, INPUT);
pinMode(TX_PIN, OUTPUT);
mySerial.begin(9600);
Serial.begin(9600);
Serial.println("Starting...");
}
void loop()
{
mySerial.print("To TSS");
Serial.println("To USB");
}
How is it that this code can use the same 2 pins with TX on pin 3 for hardware and pin 2 for the SoftwareSerial? I could see how this might work one time. I mean the setup of pin directions for softwareserial could be corrected by the hardware serial but since the setup is a one time thing, I don't see how the SoftwareSerial would continue to work. But it does.
Can anyone explain this?
Question 3:
I'm thinking about doing a cut and jumper and connecting the Mega Serial2 port to the TSS (pin 0,1), instead of using the Serial0, and reversing the TX/RX lines (crossover). That way, I could use a hardware serial to communicate between Mega and TSS.
However, I still need the FT serial driver connected to both the Mega and TSS, for program loading (using these same pins). If I just use a 1K resistor, like between the FT driver and the Mega, would that be enough isolation to prevent conflict with other serial ports?
As it is now, using the SoftwareSerial, when the Mega is communicating with the TSS, the FT driver is still connected but seperated by that 1K resistor. It would seem that if I just stopped using the SoftwareSerial and used the Serial2 (with crossover), it wouldn't be electrically any different, with regards to serial conflicts between connections.