Parallel Bus replaced with 74HC595

Hi folks,

I've just got my LCD with LC7981 Chipset all setup and running but now I need some more free pins on the AVR/Arduino.

Just until now, I connected every data and control pin from the display to the AVR. Now I'm trying to replace the 8 datalines (DB0-DB7) with one 74HC595 shift register.

This is my original code, which works pretty well:

// Puts data onto the data pins
void DG16080::data(unsigned int data) {
  digitalWrite(_DB0, bitRead(data, 0));
  digitalWrite(_DB1, bitRead(data, 1));
  digitalWrite(_DB2, bitRead(data, 2));
  digitalWrite(_DB3, bitRead(data, 3));
  digitalWrite(_DB4, bitRead(data, 4));
  digitalWrite(_DB5, bitRead(data, 5));
  digitalWrite(_DB6, bitRead(data, 6));
  digitalWrite(_DB7, bitRead(data, 7));
}

When replacing this routine with this one:

void DG16080::data(unsigned int data) {
  digitalWrite(_LATCH, LOW);
  shiftOut(_DATA, _CLOCK, LSBFIRST, data);   
  digitalWrite(_LATCH, HIGH);
}

I'm in trouble. From your point of view, are these codes comparable or is the 595-variant (2nd code block) trash?

I've already tested output of the 595-variant with different values and it seems this code is working well.

I connected DB0 to Q0, DB1 to Q1 and so on.

Please let me know your thoughts.

Thanks in advance

It looks OK to me.

I don't quite get the question. You are saying your second code block works, but not in the context of being used in place of the first code block?

One possible problem - the second version might be slightly faster. Try adding a small delay.