Following instruction from https://www.pjrc.com/teensy/td_serial.html, I use this code to read data from PC host:
Two observations:
1. by measuring the testpin, I found the data rate is about 5Mbyte/second.
2. the number 128 in bytecount< 128 cannot be too large. If I set it to such as 256, I start to loose data.
I am trying to get fast data throughput. I have tested it is very fast to send data from Teensy to PC, but the direction from PC to Teensy seems to be slower. Is this by design?
Code:
unsigned char bytecount = 0;
while (SerialUSB1.available() && bytecount< 128) {
toggle=!toggle;
digitalWriteFast(TESTPin,toggle);
readBuffer[bytecount]= SerialUSB1.read();
//SerialUSB1.readBytes();
bytecount++;
}
if(bytecount>0){
ProcessInput(readBuffer,bytecount);
}
Two observations:
1. by measuring the testpin, I found the data rate is about 5Mbyte/second.
2. the number 128 in bytecount< 128 cannot be too large. If I set it to such as 256, I start to loose data.
I am trying to get fast data throughput. I have tested it is very fast to send data from Teensy to PC, but the direction from PC to Teensy seems to be slower. Is this by design?