no_user_name
Member
Hello,
I am trying to communicate via serial interface between Teensy LC and Teensy 3.5 using RS-485-Transceiver (https://www.sparkfun.com/products/10124). I'd like to transmit data at 3 000 000 baud (Teensy 3.5 runs only at 96MHz).
I uncommented the line to activate 9 bit data format in HardwareSerial.h because I like to use the address match feature of the UARTs and use the 9th bit as address mark bit, later:
I tested communication by sending 32 byte data frames:
At 500 000 baud everything works fine. But when I increase the baudrate to 1 500 000 baud or 3 000 000 baud writing to the transmit buffer with Serial1.write() takes longer in comparison to lower baudrates.
For the first two 32-byte-frames it takes only around 105 microseconds to return for Serial1.write() at 500 000 baud (Following frames take more time because of the 64-byte transmit buffer).
For higher baudrates it takes around 300 microseconds to return for Serial1.write().
I know that the duration for Serial1.write() to return is no measurement for the UART's speed, because Serial1.write() just writes to the TX buffer of the HardwareSerial object, which is transmitted byte by byte at the specified baudrate and the return of Serial1.write() does not mean all data has already been transmitted. But why does it take longer for Serial1.write() to return when I increase the baudrate? Is it because data from the buffer is transmitted so fast that interrupts are stretching time for Serial1.write() that much? That would mean Serial1.write() produces an overhead of more than twice the time it takes the UART to transmit the data frames. If so, is there a possibility to speed up this process, so it will take the transmitter controller less REAL time to transmit data?
Thanks in advance!
I am trying to communicate via serial interface between Teensy LC and Teensy 3.5 using RS-485-Transceiver (https://www.sparkfun.com/products/10124). I'd like to transmit data at 3 000 000 baud (Teensy 3.5 runs only at 96MHz).
I uncommented the line to activate 9 bit data format in HardwareSerial.h because I like to use the address match feature of the UARTs and use the 9th bit as address mark bit, later:
Code:
#define SERIAL_9BIT_SUPPORT
Code:
uint8_t data[32];
for(uint8_t i = 0; i <32; i++) {
data[i] = i;
}
Serial1.write(data,32);
For the first two 32-byte-frames it takes only around 105 microseconds to return for Serial1.write() at 500 000 baud (Following frames take more time because of the 64-byte transmit buffer).
For higher baudrates it takes around 300 microseconds to return for Serial1.write().
I know that the duration for Serial1.write() to return is no measurement for the UART's speed, because Serial1.write() just writes to the TX buffer of the HardwareSerial object, which is transmitted byte by byte at the specified baudrate and the return of Serial1.write() does not mean all data has already been transmitted. But why does it take longer for Serial1.write() to return when I increase the baudrate? Is it because data from the buffer is transmitted so fast that interrupts are stretching time for Serial1.write() that much? That would mean Serial1.write() produces an overhead of more than twice the time it takes the UART to transmit the data frames. If so, is there a possibility to speed up this process, so it will take the transmitter controller less REAL time to transmit data?
Thanks in advance!