Author Topic: NHD-0420DZW-AG5 parallel interface  (Read 3191 times)

stylonurus

  • Newbie
  • *
  • Posts: 5
  • Karma: 1
    • View Profile
NHD-0420DZW-AG5 parallel interface
« on: May 22, 2014, 07:16:08 PM »
I am programming a C8051F500 (from Silicon Labs) with the OLED character display mentioned above. I am using a parallel interface as described on page 11 of the data sheet. For the most part I have it working and even wrote a small library. I then received a second display all wired correctly like the first, plugged it in and found that all the characters would now being displayed twice.
After some debugging I noticed a few things that I did not understand.

1. In the writeOledData routine I ended up commenting out the LCD_RW = 1 to stop the duplicates from occurring. Why would this make fix the problem?
    And now any character over 0x7F completely overwites the display with some character above 0x7F. Often it is a 0xB9 but after it is written, its a lot of work to get it back to normal. Loading code or power cyccling don't help. It's stuck in this bad display state????

2. In order to display the character on the display I use the toggle_E() which just performs a LCD_E = ~LCD_E
    If I try to use implicit calls LCD_E = 1 followed by LCD_E =0 around the P4=cmd statement (see below), (or vicaversa) something strange happens like the 2nd and 4th line never get displayed.   

3. Lastly, Once I get all bad characters as I mentioned above in 1, I can load from a debugger (IDE) a previously working hex and it won't matter. It still remains bad even after I power off and back on.

It would help to look at working example that uses a parallel interface. All the examples I have seen use serial. Below is the code for my data write.

Thanks


void writeOledData(U8 cmd)
{
   U8 checkBusy;
   U8 eValue;

   // write data
   LCD_RS = 1;
   LCD_RW = 0;

   toggle_E();
   P4 =  cmd;
   toggle_E();


   spinLock(1,  ONE_MS_RELOAD);      // Spin 1ms or so
   // check for busy
   //LCD_RW = 1;  // causes double characters
   //LCD_RS = 0;   // does nothing

   // As long as I write a character that has a value 0x7F or less
  // CheckBusy is always returns high bit not set
   checkBusy = P4;
   while (checkBusy & 0x80)   {
       spinLock(1,  ONE_MS_RELOAD);      // Spin 1ms or so
       checkBusy = P4;
       eValue++;
       if ( eValue >= 10) {
             toggle_E();        // This actually runs with characters higher than 0x7F and sometimes works
       }
   }

}

Michael_L

  • Administrator
  • Hero Member
  • *****
  • Posts: 356
  • Karma: 33
    • View Profile
Re: NHD-0420DZW-AG5 parallel interface
« Reply #1 on: May 23, 2014, 08:28:54 AM »
I actually have some code I can share with you.  It is written for an Arduino Uno and uses the parallel interface.  See below:

Code: [Select]
//---------------------------------------------------------
/*
NHD_0420DZW_uno.ino
Program for writing to Newhaven Display 4 x 20 Character OLED (6800 mode)

(c)2014 Mike LaVine - Newhaven Display International, LLC.

        This program is free software; you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation; either version 2 of the License, or
        (at your option) any later version.

        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.
*/
//---------------------------------------------------------

// The 8 bit data bus is connected to PORTD of the Arduino Uno R3

int RS =  8;    // RS signal connected to digital pin 8 of Arduino Uno R3
int RW =  9;    // R/W signal connected to digital pin 9 of Arduino Uno R3
int  E = 10;    // E signal connected to digital pin 10 of Arduino Uno R3

const char text1[] = {"  Newhaven Display  "};
const char text2[] = {"   Character OLED   "};
const char text3[] = {"  4 Line x 20 Char  "};
const char text4[] = {"0123456789!@#$%^&*()"};

const char text5[] = {"Line 1"};
const char text6[] = {"Line 2"};
const char text7[] = {"Line 3"};
const char text8[] = {"Line 4"};

void command(char c)

   digitalWrite(RS, LOW);
   PORTD = c;
   digitalWrite(E, HIGH);
   digitalWrite(E, LOW);
}

void data(char d)
{
   digitalWrite(RS, HIGH);
   PORTD = d;
   digitalWrite(E, HIGH);
   digitalWrite(E, LOW);
}

void disp1()
{
   int i;
   command(0x02);  //Home Command  [Set DDRAM address to Line 1 position 1]
   delay(5);
   for (i=0;i<20;i++)
   {
      data(text1[i]);
   }
   command(0xC0);  //Second Line  [Set DDRAM address to Line 2 position 1]
   for (i=0;i<20;i++)
   {
      data(text2[i]);
   }
   command(0x94);  //Third Line  [Set DDRAM address to Line 3 position 1]
   for (i=0;i<20;i++)
   {
      data(text3[i]);
   }
   command(0xD4);  //Fourth Line  [Set DDRAM address to Line 4 position 1]
   for (i=0;i<20;i++)
   {
      data(text4[i]);
   }
}

void disp2()
{
   int i;
   command(0x02);  //Home Command  [Set DDRAM address to Line 1 position 1]
   delay(5);
   for (i=0;i<6;i++)
   {
      data(text5[i]);
   }
   delay(250);
   for (i=0;i<14;i++)
   {
      command(0x1C);
      delay(40);
   }
   command(0x01);  //Display Clear
   delay(2);
   command(0x02);  //Home Command  [Set DDRAM address to Line 1 position 1]
   command(0xC0);  //Second Line  [Set DDRAM address to Line 2 position 1]
   for (i=0;i<6;i++)
   {
      data(text6[i]);
   }
   delay(250);
   for (i=0;i<14;i++)
   {
      command(0x1C);
      delay(40);
   }
   command(0x01);  //Display Clear
   delay(2);
   command(0x02);  //Home Command  [Set DDRAM address to Line 1 position 1]
   command(0x94);  //Third Line  [Set DDRAM address to Line 3 position 1]
   for (i=0;i<6;i++)
   {
      data(text7[i]);
   }
   delay(250);
   for (i=0;i<14;i++)
   {
      command(0x1C);
      delay(40);
   }
   command(0x01);  //Display Clear
   delay(2);
   command(0x02);  //Home Command  [Set DDRAM address to Line 1 position 1]
   command(0xD4);  //Fourth Line  [Set DDRAM address to Line 4 position 1]
   for (i=0;i<6;i++)
   {
      data(text8[i]);
   }
   delay(250);
   for (i=0;i<14;i++)
   {
      command(0x1C);
      delay(40);
   }
   command(0x01);  //Display Clear
   delay(2);
   command(0x02);  //Home Command  [Set DDRAM address to Line 1 position 1]
}

void setup()
{
   DDRD = 0xFF;    //set PORTD as output
   PORTD = 0x00;   //initialize PORTD to 0x00
   pinMode(RS, OUTPUT);
   pinMode(RW, OUTPUT);
   pinMode(E, OUTPUT);
   digitalWrite(RW, LOW);
   digitalWrite(E, HIGH);
   command(0x38);  //Function Set  [8-bit mode, Font Table: English/Japanese (FT[1:0] = 00)]
   command(0x08);  //Display OFF
   command(0x01);  //Display Clear
   command(0x06);  //Entry Mode Set  [Auto increment address when a character is written]
   command(0x02);  //Home Command  [Set DDRAM address to Line 1 position 1]
   command(0x0C);  //Display ON
}

void loop()

  disp1();
  delay(3500);
  command(0x01);  //Display Clear
  disp2();
  delay(50);
}


stylonurus

  • Newbie
  • *
  • Posts: 5
  • Karma: 1
    • View Profile
Re: NHD-0420DZW-AG5 parallel interface
« Reply #2 on: May 27, 2014, 03:47:03 PM »
Michael,
Thanks for posting the code for the parallel interface. This really helped me. My major problem was the toggling of E in the data write routine. I was setting it high before the write out to the PORT. If you study the diagram in the data sheet you would think that this would be correct.

I also a different sequence with RS, E and RW prior to the initialization sequence although it working none the less. Although I still have not tested it with another display, this configuration appears to be more stable than my original yet somewhat slower. Not sure why but working on it. Thanks Again. I really appreciate it.

 

Questions regarding NHD‐0220DZW‐AY5 & NHD‐0420DZW‐AY5

Started by tseyfarthBoard OLEDs

Replies: 3
Views: 2857
Last post August 20, 2015, 09:51:26 AM
by Saurabh_B
NHD‐0420CW‐AB3 I2C Interface

Started by andersonpdBoard OLEDs

Replies: 1
Views: 2628
Last post January 23, 2015, 10:00:06 AM
by Michael_L
NHD‐3.12‐25664UMB3 3 or 4 wire interface

Started by cliffgBoard OLEDs

Replies: 1
Views: 2476
Last post February 13, 2015, 04:43:21 PM
by Michael_L
NHD‐0420DZW‐AB5 Lines

Started by RickJBoard OLEDs

Replies: 1
Views: 2269
Last post January 09, 2015, 04:18:32 PM
by Michael_L
NHD-0420DZW-AG5 - Display "sometimes" shows only 2 lines

Started by stylonurusBoard OLEDs

Replies: 5
Views: 5562
Last post June 18, 2014, 10:09:49 AM
by Michael_L