NHD-0420DZW-AG5 - Display sometimes shows only 2 lines
This problem is a bit strange for me and I'm not sure if it's a hardware issue or a software issue. But I have now seen it on both of my test boards.
I am using a Silabs C8051F500 development board with jtag connection for IDE / debuggger.
Silabs board has extender board with OLED display.
Mostly everything works fine.
I have written the driver and a library of routines to write to any line of the display (parallel interface).
The problem.
When I re power the system only lines 1 and 3 are displayed. 2 and 4 are not displayed
But when I connect with the debugger and then disconnect. On the disconnect all the lines including the second and fourth line get displayed. ( might have to connect disconnect 3 or 4 times before 4 lines get displayed)
Once all 4 lines are displayed, they are always displayed.
Is this a timing issue?
A power up voltage issue?
Something else?
Please let me know if you have seen this before.
Thanks
-
This issue only happens when power cycling the display and not when being powered on for the first time? Can you share you initialization code?
0 -
Michael,
I used a delay timer called spinlock to slow things down. I've tried different delay times as well but the delay does not seem to help or change behavior.
More than not, the two lines occur on a cold power up cycle. After running a while if I quickly re power , the four lines appear most of the time. After waiting 5 seconds between powering up the 2 lines appear most of the time. I tied delaying 3 seconds after power up and before call initialization routine. It did not improve behavior.
All comments, ideas and suggestions are most welcome.
Thanks
void oledInit(void)
{
P4 = 0x00; //initialize PORT 4 to 0x00
spinLock(1, ONE_MS_RELOAD); // Spin 1 ms
LCD_RW = 0;
spinLock(1, ONE_MS_RELOAD); // Spin 1 ms
LCD_E = 1;
spinLock(1, ONE_MS_RELOAD); // Spin 1 ms
writeOledCommand(0x3B); // Function Set
writeOledCommand(0x08); // Display Off
writeOledCommand(0x01); // Display Clear
writeOledCommand(0x06); // Entry Mode Set
writeOledCommand(0x02); // Home Command
writeOledCommand(0x0C); // Display On
spinLock(5, ONE_MS_RELOAD); // Spin 5 ms
}
void writeOledCommand(U8 cmd)
{
// write command
LCD_RS = 0;
spinLock(1, ONE_MS_RELOAD);
P4 = cmd;
spinLock(1, ONE_MS_RELOAD);
LCD_E = 1;
spinLock(1, ONE_MS_RELOAD);
LCD_E = 0;
}0 -
I'm not sure of the cause of your problem, as I have just tested this with an Arduino using your initialization and have not seen the same results as you have described.
I've powered it on/off several times, and have manually reset the processor as well and in all cases all 4 lines would work.
I have copied my code below if that helps with any other areas of code that you have not shared in your last post://---------------------------------------------------------
/*
NHD_0420DZW_mega.ino
Program for writing to Newhaven Display 4 x 20 Character OLED (8-bit, 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 PORTA[7..0] of the Arduino Mega2560
int RS = 30; // RS signal connected to digital pin 30 of Arduino Mega2560
int RW = 31; // R/W signal connected to digital pin 31 of Arduino Mega2560
int E = 32; // E signal connected to digital pin 32 of Arduino Mega2560
const char text1[] = {" Newhaven Display "};
const char text2[] = {" Character OLED "};
const char text3[] = {" 4 Line x 20 Char "};
const char text4[] = {"0123456789!@#$%^&*()"};
void toggle()
{
digitalWrite(E, HIGH);
delay(1);
digitalWrite(E, LOW);
}
void command(char c)
{
PORTA = c;
digitalWrite(RS, LOW);
toggle();
}
void data(char d)
{
PORTA = d;
digitalWrite(RS, HIGH);
toggle();
}
void disp()
{
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 setup()
{
DDRA = 0xFF; //set PORTA (dat bus) as output
PORTA = 0x00; //initialize PORTA to 0x00
DDRC = 0xFF; //set PORTC (control lines) as output
PORTC = 0x00; //initialize PORTC to 0x00
command(0x3B); //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()
{
disp();
delay(3000);
}0 -
Mike,
Thanks for checking this out.
As it stands, I got this to work by writing the function set command twice in the initialization routine.
writeOledCommand(0x3B); // Function Set
writeOledCommand(0x3B); // Function Set
Looks like some voltage or wiring issue on the extender board. That' all I can think of.
Thanks again,0 -
Glad you got it working, thank you for sharing!
0
Please sign in to leave a comment.
Comments
5 comments