Improve LCD Writting commands

I am modifying a library to print in the fastest ammount of time possible. So far I can fill a 16x2 HD44780 lcd in about 2ms, but i would like to go further.

I have this loop in the code

   for ( i = 0; i < 4; i++ )
   {
      pinMode ( _data_pins[i], OUTPUT );
   }

   pinMode(_rs_pin, OUTPUT);
   pinMode(_enable_pin, OUTPUT);
   
   // Initialise displaymode functions to defaults: LCD_1LINE and LCD_5x8DOTS
   // -------------------------------------------------------------------------
   
   _displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS;

for (uint8_t i = 0; i < numBits; i++) 
   {
      //data = (_data_pins[i], (value >> i) & 0x01);
     //digitalWrite(_data_pins[i], (value >> i) & 0x01);
     
    digitalWrite(_enable_pin, HIGH); 
    digitalWrite(_data_pins[i], (value >> i) & 0x01);
     
     //digitalWrite((_data_pins0, (value 0) & 0x01);
     //digitalWrite((_data_pins1, (value 1) & 0x01);
     //digitalWrite((_data_pins2, (value 2) & 0x01);
    // digitalWrite((_data_pins3, (value 3) & 0x01);
     //delay(200);

Which basically prints one out of 4 bits at a time. When I designed the hardware I made sure these pins were all toguether, so i should be able to write them in a single instruction.

The pinouts is as follows

D4 - PD4 - Arduino Pin4
D5 - PD5 - Arduino Pin5
D6 - PD6 - Arduino Pin6
D7 - PD7 - Arduino Pin7

Can I have any examples on how to archieve this?

To increase your speed, and simplify things, you should use the full 8 bit interface, not a 4 bit interface.

Using PD0 - PD7 as your pins D0 - D7 on the LCD would mean you can then control them with a simple

PORTD=<value>;

set the RS line (or C/D depending on how it's labelled), and pulse the E line. Can't get faster than that :slight_smile: