I'm trying to send bytes between two Teensy 3s but can't seem to transfer them any faster by raising the baud past 115200.
No matter how high I raise the baud it still takes ~11us to send the two bytes and about 2-3us to read them. Eventually at around 1.5MHz it locks up.
I've tried Serial2 and 3 but since they don't have FIFOs both bytes aren't received in the same cycle (I guess?)
On my scope I do see the frequency going faster when I change it about 115200.
I saw the other posts on UARTS, specifically http://forum.pjrc.com/threads/23687-Teensy-3-0-UART-datarate, but I'm wondering if there's another setting I'm missing or if its just that higher rates don't work or there's a bottleneck I'm missing.
Code:
HardwareSerial Uart = HardwareSerial();
byte j,RX,g;
long d,t,prev;
#define rate 115200*10
void setup() {
//Uart.begin(115200);
Uart.begin(rate);
Serial.begin(rate);
pinMode(13,OUTPUT);
pinMode(2,INPUT_PULLUP);
}
void loop() {
if (digitalRead(2)==0){
RX=0;
}
else{
RX=1;
}
//////////////// SEND
if (RX==0){
if ((millis()-prev)>500 ){
j++;
g+=64;
prev=millis();
t=micros();
Uart.write(j);
Uart.write(d);
d=micros()-t;
}
if (g>0){
g--;
digitalWrite(13, HIGH);
}
if (g==0){
digitalWrite(13, LOW);
}
if (g==1){
Serial.println(d);
}
}
////////////////////////// RECIEVE
if (RX==1){
/*
int incomingByte;
if (Serial.available() > 0) {
incomingByte = Serial.read();
Serial.print("USB received: ");
Serial.println(incomingByte, DEC);
// Uart.print("USB received:");
// Uart.println(incomingByte, DEC);
}
*/
if (Uart.available()) {
j+=128;
t=micros();
byte b1 = Uart.read();
byte b2 = Uart.read();
d=micros()-t;
Serial.print(b1);
Serial.print(" ");
Serial.println(b2);
Serial.print(" ");
Serial.println(d);
}
if (j>0){
j--;
digitalWrite(13, HIGH);
}
if (j==0){
digitalWrite(13, LOW);
}
}
}
No matter how high I raise the baud it still takes ~11us to send the two bytes and about 2-3us to read them. Eventually at around 1.5MHz it locks up.
I've tried Serial2 and 3 but since they don't have FIFOs both bytes aren't received in the same cycle (I guess?)
On my scope I do see the frequency going faster when I change it about 115200.
I saw the other posts on UARTS, specifically http://forum.pjrc.com/threads/23687-Teensy-3-0-UART-datarate, but I'm wondering if there's another setting I'm missing or if its just that higher rates don't work or there's a bottleneck I'm missing.