Hi,
I am new in the teensy world. I am trying to communicating a teensy 3.6 with e teensy 3.2 via serial port. For teensy 3.6 I am using Serial3 port and for teensy 3.2 I am using Serial1 port. Here is the code:
What I am trying to do, I am sending letter 'a' from teensy 3.6 to teensy 3.2 with a timer generated interrupt and again I am sending it back from teensy 3.2 to teensy 3.6.
Another question, what should be maximum baud rate for this particular case (teensy to teensy)?
Let me know what I am doing wrong!
I am new in the teensy world. I am trying to communicating a teensy 3.6 with e teensy 3.2 via serial port. For teensy 3.6 I am using Serial3 port and for teensy 3.2 I am using Serial1 port. Here is the code:
Code:
//code for teensy 3.6
#define Ts 20000
boolean timerFlag;
IntervalTimer myTimer;
void timerISR(void) {
timerFlag = true;
}
void setup() {
Serial3.begin(38400);
Serial.begin(38400); // Config serial port (USB)
while(!Serial);
while(!Serial3);
myTimer.begin(timerISR,Ts);
}
void loop() {
Serial.println("master");
if(timerFlag) {
timerFlag = false;
Serial3.write('a');
Serial3.flush();
delayMicroseconds(100);
if (Serial3.available()) //teensy 3.2 detected
{
if (Serial3.read() == 'a') //accept response from teensy 3.2,connection stablished
{
Serial.println("response received: ");
}
}
}
}
Code:
//Receiver Code
//code for teensy 3.2
char command;
void setup() {
Serial.begin(38400);
Serial1.begin(38400);
while(!Serial);
while(!Serial1);
}
void loop() {
if (Serial1.available()) //wait for teensy 3.6
{
Serial.println("command received");
command = Serial1.read();
if(command == 'a')
{
Serial.println("Hello");
Serial1.write('a'); //send response to teensy 3.6
Serial1.flush();
}
}
}
What I am trying to do, I am sending letter 'a' from teensy 3.6 to teensy 3.2 with a timer generated interrupt and again I am sending it back from teensy 3.2 to teensy 3.6.
Another question, what should be maximum baud rate for this particular case (teensy to teensy)?
Let me know what I am doing wrong!