Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

new lcd

Status
Not open for further replies.

Dr_Doggy

Well-Known Member
hi guys, i got this lcd screen, but I cant read this datasheet, first there is no cs2 which is !cs so im not too worried about it,
BUT look at truth table, there is A0, /rd, /wr, but rd & wr is a state of a0, so when/how do i switch it?

pls just a simple psudo is all i need , just something to make a few pixles appear , ie

cs
switch a
shift instruction
switch rd
shift data
cs off

thnx!
 

Attachments

  • SUPER LCD.pdf
    645.5 KB · Views: 313
I don't think that you can read anything from it, because there's no SO line anyway (which they used to have on their LCDs). So, I would simply ignore the /RD /WR columns.

I think you just use SI and SCL to bit-bang the commands to the display.
 
in a error of reading pins upside down and some fast rewire my pins got redirected to the following ports:


TRISDbits.TRISD5 = 0;LATDbits.LATD5 = 0; // A0
TRISDbits.TRISD6 = 0;LATDbits.LATD6 = 0; // SDAT
TRISDbits.TRISD7 = 0;LATDbits.LATD7 = 0; // SCLK
TRISDbits.TRISD4 = 0;LATDbits.LATD4 = 1; // RESET
TRISCbits.TRISC5 = 0;LATCbits.LATC5 = 1; // CS

so code will no go, but i have pulled out old spi code, and set up pins, (also tried to integrate example code frm datasheet)
Code:
void INSTRUCT (unsigned char  CHIPVAL)
{  
   unsigned char  COUNTS2;
   for (COUNTS2=1;COUNTS2<9;COUNTS2++)
   {  
     if (CHIPVAL > 127) {LATDbits.LATD6 = 1; CHIPVAL = CHIPVAL - 128;}
     else {LATDbits.LATD6 = 0;}
     CHIPVAL = CHIPVAL * 2;
     LATDbits.LATD7 = 1;
     LATDbits.LATD7 = 0;
   }
     LATCbits.LATC5 = 1;
}
void READYCHIP (unsigned char a)
{    
     LATCbits.LATC5 = 0;
     INSTRUCT (a);
     LATCbits.LATC5 = 1;
     LATCbits.LATC5 = 0;
}

and MAIN:

Code:
void main (){
while (1){
for (xx=1;xx<250;xx++){


        READYCHIP (xx);
        INSTRUCT (xx);

        LATCbits.LATC5 = 1;
}}}

but wait, and if im reading sheet properly to write to lcd any data will write when a0 and /rd are high, again i dont have read write pins, only a0??
 
also i have tried integrating the initialization code off your example with not even a blip
Code:
void LCD_Send(unsigned char ch, unsigned char type)
    {
//    DC = type;        // Command or Data     what is DC>??????
    LATCbits.LATC5 = 0;            //
    INSTRUCT (ch);    //WriteSPI(ch);    // WriteSPI
    LATCbits.LATC5 = 1;
    }

//-------------------------------------------------------------
// Function to RESET the screen..
// no arguments
//-------------------------------------------------------------
void LCD_Reset(void)
    {
    LATCbits.LATC5 = 1;
    Delay1KTCYx(17);    //Delay 85mS
    LATDbits.LATD4 = 1;
    Delay1KTCYx(17);    //Delay 85mS
    }

void INSTRUCT (unsigned char  CHIPVAL)
{
    unsigned char  COUNTS2;
    for (COUNTS2=1;COUNTS2<9;COUNTS2++)
    {
        if (CHIPVAL > 127) {LATDbits.LATD6 = 1; CHIPVAL = CHIPVAL - 128;}
        else {LATDbits.LATD6 = 0;}
        CHIPVAL = CHIPVAL * 2;
        LATDbits.LATD7 = 1;
        LATDbits.LATD7 = 0;
    }

        LATCbits.LATC5 = 1;
}

void main (){


    Delay1KTCYx(17);    //Delay 85mS
    LCD_Reset();
    LCD_Send(0xA6,0);    //Display: Normal
    LCD_Send(0xA3,0);    //LCD Bias Settings: 1/7
    LCD_Send(0xA1,0);    //ADC Selection: Reverse
    LCD_Send(0x40,0);    //Set the start line
    LCD_Send(0xAF,0);    //LCD On
    LCD_Send(0xA5,0);    //Display All Points: ON
    Delay10KTCYx(200);    //Delay 170mS
    LCD_Send(0xA4,0);    //Display All Points:RMAL
 

}

maybe i should try new LCD, i did install it upside down by accident origionally....
(hardware connections wired and responding ok now)
 
I looked at my code for NHD0420DZW. In purely serial mode, each command would consist of 10 bits - RS bit (data/command), RW bit (read/write), then 8 bits of the data. For example to send a command (RS=0):

bclr DISPLAY_LAT, #DISPLAY_CS
rcall display_write_zero ; RS = 0
rcall display_write_zero ; RW = 0
rcall display_write_byte
bset DISPLAY_LAT, #DISPLAY_CS

There's only few possible combinations to consider:

A0 - either sent like a bit or hardrawe signal
RW/RD - either both sent or one of them sent, or none.

It won't show you anything until you initizlize properly, including considerable wait for the clear command. Here's my initialization sequence (don't know if it will work for yours):

.byte 0x38 + DISPLAY_TABLE ; function set
.byte 0x08 ; display off
.byte 0x01 ; clear display
.byte 0x06 ; I/D = 1; S = 0
.byte 0x02 ; return home
.byte 0x0c ; display on
 
ok well thats np , i have int code off data sheet which goes:

main (){
Code:
INSTRUCT (0,2,0xA0);
INSTRUCT (0,2,0xAE); // display off
INSTRUCT (0,2,0xC0);
INSTRUCT (0,2,0xA2);
INSTRUCT (0,2,0x2F);
INSTRUCT (0,2,0x26);
INSTRUCT (0,2,0x81);
INSTRUCT (0,2,0x11); //set address upper bit
INSTRUCT (0,2,0xAF); // dislpay on


  Delay10KTCYx(10);


while (1){


LCDb(6);

     INSTRUCT (0,2,165);     Delay100TCYx(100);
     INSTRUCT (0,2,164);     Delay100TCYx(100);
}}

while switching over the lang i also looked up the val for a0, but in every instance it is 0, so that solves that for now, but a0 is a hard pin, and clocks in at d0.

also going through this again i have noticed that RW != RD always... but have tried on both 1st & 2nd clock bits, aswell as the 1st bit alone. also im shifting MSB first, correct!?

Code:
void INSTRUCT (unsigned char A0, unsigned char RW, unsigned char  CHIPVAL)
{  
    unsigned char  COUNTS2;
    LATCbits.LATC5 = 0;    // cs
    if (A0 == 1){LATDbits.LATD5 = 1;} else {LATDbits.LATD5 = 0;}
    if (RW == 1){LATDbits.LATD6 = 1;} else {LATDbits.LATD6 = 0;}

        LATDbits.LATD7 = 1;        LATDbits.LATD7 = 1;       //   CLOCK
        LATDbits.LATD7 = 0;        LATDbits.LATD7 = 0;     //    PULSE


    for (COUNTS2=0;COUNTS2<8;COUNTS2++)
    {  
        if (CHIPVAL > 127) {LATDbits.LATD6 = 1; CHIPVAL = CHIPVAL - 128;}else {LATDbits.LATD6 = 0;}
        CHIPVAL = CHIPVAL * 2;
        LATDbits.LATD7 = 1;    LATDbits.LATD7 = 1;    //CLOCK
        LATDbits.LATD7 = 0;    LATDbits.LATD7 = 0;   //PULSE
    }
LATCbits.LATC5 = 1;
}

but still is nothing...
 
When you send data to the LCD:

INSTRUCT (0,2,165); Delay100TCYx(100);
INSTRUCT (0,2,164); Delay100TCYx(100);

The data bit (A0?) is supposed to be set. This is how it tells data from commands.

The data sheet doesn't give much details, but they do have a test code. I commented it as I understand it:

Code:
Sub   Command
  Reset  P3.7  ; CS down
  Reset  P3.4  ; A0 down
  For Writecount  =  1  To  8
  Rotate  A   ,  Left   ,  1
  Reset  P3.1 ;  SCL down
  P1  =  A ; set SI
  Set  P3.1  ; SCL up
  Next  Writecount
  Set  P3.7  ; CS up
End Sub

When you send data (characters), their example is the same, but A0 is up.

That's quite different from mine.

Whewn initializing, try wait few ms between each command.
 
thnx guys for staying with this here, but you were rite from post 1 & 2, turns out my biggest problem was that i had 2 pins mixed, a0 & ck, I also have never initialized an lcd before so that was new too, simple, but i thought it to be non-essential, but we still have that mystery of how to call command 6, where a0 = 1 and /rd = 1, either way who cares!!! i contacted digikey and my(digikeys) sheet was 1/10th the size of the manuf one that they gave me, i'm going to guess that the sheet was chopped from another similar one, since theirs showed /cs1 & /cs2 and other pins i didnt have. I was also able to remove all the delays and bump that clock up to full speed with great results

so thnx again!

also! i thought i'd take the time to share the vb6 program i made:
it is able to import a b/w bit bitmap off the HD or freehand draw an image.
it can then take that image and convert it to 128x64 resolution,
then convert to both bytecode
then compress to hex,
then trim the top and left 0's
giving me a nice hex sprite for my LDC

i have included source code for ones like me who dont like exe's!

(18f4620)
i have seen alot of topics about lcd code, and idk if im interested in extending any buffers or anything crazy, i was thinking about just going off eeprom to a few write arrays, would that sound good for efficient coding?
 

Attachments

  • VB6CODE.rar
    9.2 KB · Views: 119
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top