Author Topic: Need help please with NHD-0420D3Z-fl-GBW-V3  (Read 2636 times)

Dave

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
    • View Profile
Need help please with NHD-0420D3Z-fl-GBW-V3
« on: March 02, 2015, 09:29:51 AM »
Has anyone used this display in the SPI mode with a Pic processor(pic18f2620)? If so any code to share?

Iíve tried using the SPI peripheral and straight bit bang, still canít get the display to work other than in test mode.
I have R2 shorted with a zero ohm 0603 resistor,I have set the CKP to 1 and the CKE to 1, the clock is set to 62.5kHz. I also tried different modes (grasping at straws now). Looking at the signals with a scope and all seems well, seeing as there are now timing diagrams to check against.
As I understand it when the display powers up, it powers up in the on mode, therefore all I should have to do is send 0x13(code for the #1), and the display should display a ď1Ē, I got nothing, I even tried turning on the display, setting the curser to home first.

SPI INITALIZATION CODE
void initialize_spi()
{
   
    LATBbits.LATB4 = 1;/*disable lcd*/
     SSPCON1 = 0;
    SSPCON1bits.SSPEN = 0;/*Synchronous Serial Port Enable bit  DISABLED*/
    SSPCON1bits.SSPM = 2;/*SPI Master mode, clock = FOSC/64*/
    SSPCON1bits.CKP = 1;/*Clock Polarity Select bit*/
    SSPSTATbits.CKE = 1;/*SPI Clock Edge Select bit (SPI mode only)*/

    }

LCD TEST FUNCTION
void test()
{
   
    LATBbits.LATB4 = 0;/*Set LCD select low*/
    Delay10TCYx(20);
   
    PIR1bits.SSPIF = 0;/*clear Synchronous Serial Port Interrupt Flag bit*/
    SSPBUF = 0x13;
    while(!PIR1bits.SSPIF);/*The transmission/reception is complete (must be cleared in software)*/
    Delay10TCYx(20);
   LATBbits.LATB4 = 1;/*Set LCD select high*/

  }
//******************************************************
Second test function bit bang
void lcd_test(unsigned char DATA)
{
    unsigned int n,x;
    unsigned char data;
    data = DATA;
    LCD_SEL = 0;/*Set LCD select low*/
     for(n = 0; n<8;n++)
     {
         if((data & 0x80) == 0x80) SDO = 1; /*LATCbits.LATC5 = 1;*/
         else SDO = 0; /*LATCbits.LATC5 = 0;*/
         data = data << 1;
         SCK = 0;
         Delay10TCYx(1);
         SCK = 1;
      }
     SCK = 1;/*set clock high*/
     LCD_SEL = 1;/*Set LCD select high*/
}
I can see no reason why this isnít working, other than the SPI front end on the display is Tango Uniform.

Retheesh_M

  • Guest
Re: Need help please with NHD-0420D3Z-fl-GBW-V3
« Reply #1 on: March 02, 2015, 02:38:39 PM »
I noticed that in your code you used 0x13 to display a "1".  You are reading the chart in the opposite way: The top or column numbers are the high bits and the side or row numbers are the low bits.  So to display a "1", you would send 0x31 .  Also, here's some sample code that might help you out:-


Code: [Select]
#include <REG52.H>
/*****************************************************/
int a;
code char text1[]={"Newhaven Display LCD"};
//code char text2[]={" NHD-0420D3Z-FL-GBW "};
//code char text3[]={"4 Lines 20 Character"};
//code char text4[]={" Serial LCD Display "};
/*****************************************************/
sbit SDA = P1^0; //Serial data
sbit SCL = P3^4; //Serial clock
sbit SS  = P3^7; //Slave select
/*****************************************************/
const char Slave = 0x7E;
const char Comsend = 0x00;
const char Datasend = 0x40;
/*****************************************************/
void delay(unsigned int n)
{
unsigned int i,j;
for (i=0;i<n;i++)
  for (j=0;j<350;j++)
  {;}
}
/*****************************************************/
void SPI_out(unsigned char j)
{
int n;
unsigned char d;
d=j;
SS=0;
for(n=0;n<8;n++){
if((d&0x80)==0x80)
SDA=1;
else
SDA=0;
d=(d<<1);
SCL = 0;
SCL = 1;
}
SCL = 1;
SS = 1;
}
/*****************************************************/
void disp(unsigned char *text)
{
int n;
for(n=0;n<20;n++)
{
SPI_out(*text);
text++;
}
}
/*****************************************************/
int main(void)
{
P1 = 0;
P3 = 0;
delay(50);

SPI_out(0xFE);
SPI_out(0x52); //Set contrast
SPI_out(0x25); //value

SPI_out(0xFE);
SPI_out(0x53); //Set backlight
SPI_out(0x07); //value

while(1)
{
SPI_out(0xFE);
SPI_out(0x51); //clear display
delay(100);
SPI_out(0xFE);
SPI_out(0x46); //cursor home
SPI_out(0xFE);
SPI_out(0x70); //display firmware
delay(500);

SPI_out(0xFE);
SPI_out(0x54); //load custom character
SPI_out(0x00); //custom character 1
SPI_out(0x08);
SPI_out(0x08);
SPI_out(0x08);
SPI_out(0x08);
SPI_out(0x08);
SPI_out(0x08);
SPI_out(0x08);
SPI_out(0x08);

SPI_out(0xFE);
SPI_out(0x54); //load custom character
SPI_out(0x01); //custom character 2
SPI_out(0x18);
SPI_out(0x18);
SPI_out(0x18);
SPI_out(0x18);
SPI_out(0x18);
SPI_out(0x18);
SPI_out(0x18);
SPI_out(0x18);

SPI_out(0xFE);
SPI_out(0x54); //load custom character
SPI_out(0x02); //custom character 3
SPI_out(0x00);
SPI_out(0x00);
SPI_out(0x00);
SPI_out(0xFF);
SPI_out(0x00);
SPI_out(0x00);
SPI_out(0x00);
SPI_out(0x00);

SPI_out(0xFE);
SPI_out(0x54); //load custom character
SPI_out(0x03); //custom character 4
SPI_out(0x00);
SPI_out(0x00);
SPI_out(0x00);
SPI_out(0xFF);
SPI_out(0xFF);
SPI_out(0x00);
SPI_out(0x00);
SPI_out(0x00);

SPI_out(0xFE);
SPI_out(0x51); //clear display
SPI_out(0xFE);
SPI_out(0x46); //cursor home
disp(text1);
SPI_out(0xFE);
SPI_out(0x45);     //set cursor
SPI_out(0x40); //line 2
SPI_out(0x00); //custom character 1 (one vertical line)
SPI_out(0x01); //custom character 2 (two vertical lines)
SPI_out(0x02);     //custom character 3 (one horizontal line)
SPI_out(0x03); //custom character 4 (two horizontal lines)
delay(500);

delay(100);
}
}
« Last Edit: March 09, 2015, 02:25:54 PM by Retheesh_M »

Dave

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
    • View Profile
Lesson learned
« Reply #2 on: March 04, 2015, 07:29:00 AM »
See prior post for issue. Bottom line, my code worked from the start, the problem was that the SCK pin on PIC processor on the display was not soldered!
Should have gone with my instinct and checked the display first. Getting old sks

Atif_K

  • Administrator
  • Newbie
  • *****
  • Posts: 1
  • Karma: 0
    • View Profile
Re: Need help please with NHD-0420D3Z-fl-GBW-V3
« Reply #3 on: March 04, 2015, 08:11:39 AM »
Dave, I'm sorry to hear this was a result of an improper solder joint on the display. We have a set quality control process that is followed for every part so I'm not sure how this one got through, but we will make a note to double-check this type of issue during our QC inspections. I apologize for the inconvenience.

 

RS232 PIC CCS COMPILER COMANDS FOR NHD-0420D3Z-NSW-BBW-V3 ISSUE

Started by DavidVMBoard Character LCDs

Replies: 2
Views: 489
Last post May 30, 2017, 12:58:32 PM
by DavidVM
NHD-0420D3Z-NSW-BBW-V3 i2c display and Arduino missing characters

Started by 0miker0Board Character LCDs

Replies: 0
Views: 477
Last post July 06, 2017, 11:05:59 AM
by 0miker0
NHD-0420D3Z-NSW-BBW-V3 back-light flickers

Started by rickford66Board Character LCDs

Replies: 3
Views: 3295
Last post May 06, 2015, 08:34:09 AM
by fraryb
Changing the Slave Address with NHD-0420D3Z

Started by alkBoard Character LCDs

Replies: 2
Views: 2406
Last post January 13, 2015, 01:53:20 PM
by alk
Trouble with serial interface on NHD-0420D3Z-FL-GBW-V3

Started by chughesBoard Character LCDs

Replies: 4
Views: 2728
Last post September 29, 2015, 11:16:48 AM
by Paul_B