The rate of the LCD update is mostly based on the s/w not the h/w.
The reason I say mostly is that update speed is based on two things:
- How fast the s/w can get the byte to the interface h/w
- the speed of the interface h/w
The maximum speed that a hd44780 LCD can process bytes is 1 byte every 1us using direct pin control.
That is when using 8 data pins in 8 bit mode.
In 4 pin mode, it is just a bit less than half that.
The speed of the LCD is not the issue.
If you are using a PCF8574 based backpack, the rate at which you can send bytes to the LCD is dramatically slowed down since you have to transfer multiple bytes over the i2c bus to get a single byte to the LCD and the i2c bus is normally only running at 100Khz. So you can see that even if the s/w overhead was zero, there is no way to send bytes to the LCD over i2c using an i2c backpack and keep up with a 115200 baud connection.
Depending on the serial RX buffer size and the size of LCD message, you can overrun the buffer even if writing the LCD while receiving serial data.
here are some timings using a 16Mhz AVR. The specific processor doesn't matter.
When using a PCF8574 based backpack.
The hd44780 library can transfer a byte to the LCD in about 500us.
All the other libraries will take over 1ms per byte.
If you bump the SCLK of the bus to 400 kHz (which is beyond spec for the PCF8574)
The hd44780 library can transfer a byte to the LCD in about 200us
For direct pin control of the LCD using 4 pin mode.
The hd44780 library can transfer a byte to the LCD in 91us
The latest LiquidCrystal library can transfer a byte to the LCD in 284us
Using these numbers you can do the math to calculate how large your RX buffer needs to for the way you are sending the data, and update speed of the h/w interface based on the library being used.
If you are not already using the hd44780 library and you want faster LCD updates, then you will want to switch to using the hd44780 library.
The hd44780 library can also perform long line wrapping, which can be useful in some use cases.
It isn't' clear exactly what you are wanting to do in terms of updating the display and what form the data is in.
In order push an entire screen to a 40x2 LCD all at once, you are going to have to modify and / or write some code.
If you are periodically slamming all 80 bytes to update the display and the existing SerialDisplay example would have worked if there were no buffering issues, then you may want to modify the HardwareSerial.cpp code down in the Arduino AVR bundled core library to simply increase the buffer to 128 bytes instead of 64 bytes.
If you need something more sophisticated that can do LCD updates while receiving data, you will need to write you own sketch.
There are different ways to handle clearing/repositioning the display between updates.
for example
It can be character based. i.e. look for a or tor some other data value to determine the end of a message
If you are doing frequent updates of the entire LCD, then you likely don't want to clear the LCD between updates as that will cause unnecessary flicker.
You will likely want to detect "message" boundaries based on time.
For example, if the code notices that more than 1/2 or 3/4 of the update time being used by the sender has elapsed without receiving any characters then the code should set the LCD cursor position to 0,0 to get ready for the next update.
You should never write the code to assume no characters will ever get lost or that an extra character will never show up.
i.e. doing something simple like just writing each byte to LCD memory and assume that each update will fill the full DDRAM memory and wrap back to the beginning for the next update.
While that can work, if there is ever a lost character or an extra garbage character ever shows up in the data stream, the system will never recover whereas if it was doing something time based to detect a message boundary, the screen would recover on the next update.
BTW,
If you want to see the code that will be in the next hd44780 library update I have provided links to the i2c and pin control versions
The code is meant for text based messages.
It use and to mark update boundaries and enables line wrapping for long lines.
--- bill