Communicating with a 2x16 serial LCD (sparkfun)

Hi,

I purchased a serial enabled LCD display some time ago (http://www.sparkfun.com/commerce/produc … cts_id=813). The display works ok so far. Only recently, I had a need to minimize serial communication duration due to timing constraints in my code by increasing the baud rate.

If I change the display to another baud rate than 9600 by eg.

  Serial.begin(9600);
  Serial.print(0x7C, BYTE);
  Serial.print(0x0F, BYTE); // 19200

afterwards change the Arduino comm speed

  Serial.begin(19200);
  //  Serial.print(0x7C, BYTE);
  // Serial.print(0x0F, BYTE); // 19200

it however just shows garbage. It goes without saying that it can be only reset to 9600 by sending Ctrl^R. I checked out all other baudrates as well, none of them works. The Arduino sends its stuff correctly, which I verified in the serial monitor with the appropriate baudrate set.

Can anybody owning such a device please check if this is generally valid for those displays? I can’t imagine that I’m doing anything wrong here, I nevertheless attach the code I’m using:

void setDisplayBaudRate(int baudrate) {
  Serial.print(0x7C, BYTE); // command byte
  switch (baudrate) {
    case 2400:
      Serial.print(0x0B, BYTE); // Ctrl^K
      break;        
    case 4800:
      Serial.print(0x0C, BYTE); // Ctrl^L
      break;      
    case 9600:
      Serial.print(0x0D, BYTE); // Ctrl^M
      break;      
    case 14400:
      Serial.print(0x0E, BYTE); // Ctrl^N
      break;      
    case 19200:
      Serial.print(0x0F, BYTE); // Ctrl^O
      break;      
    case 38400:
      Serial.print(0x10, BYTE); // Ctrl^P
      break;  
    default:
      Serial.print(0x12, BYTE); // reset to 9600, Ctrl^R
  }
}

Thanks in advance,

/Markus

Hi,

after spending significant time narrowing down this issue, it turned out that generous pauses between the commands are the solution.

One misunderstanding originating from the documentation is that the baudrate is stored persistently. The display however resets itself to 9600 when powered down.

It works ok when I initialize my sketch with

void setup()
{
  Serial.begin(9600);
  delay(100);
  setDisplayBaudRate(19200);
  delay(100);
  Serial.begin(19200); 

...