# LCD SPLC780D Initialization sequence fails

Microcontroller model : PIC32MX340F512H
LCD controller : SPLC780D
LCD module : MC42005A6W-FPTLW3-V2 (20*4)

I have been struggling for two weeks to get a SPL780D based LCD module to work. I checked the wiring and the code with the timers many times, based on the datasheet and a lot of examples. Alone, and with other people.

I use this function to send instructions to the LCD module:

void send(int rs, int rw, unsigned char db)
{
RS = rs;
RW = rw;
wait(1000);//26ms
E = 1;
wait_k(1000);
DB0 = (db & (1 << 0)) ? 1:0;
DB1 = (db & (1 << 1)) ? 1:0;
DB2 = (db & (1 << 2)) ? 1:0;
DB3 = (db & (1 << 3)) ? 1:0;
DB4 = (db & (1 << 4)) ? 1:0;
DB5 = (db & (1 << 5)) ? 1:0;
DB6 = (db & (1 << 6)) ? 1:0;
DB7 = (db & (1 << 7)) ? 1:0;
wait_k(1000);
E = 0;
}


I tried many other delays, and I follow the sequence below:

Can someone please help me? Launching the sequence makes the screen blink once, and then I only have two lines of black boxes.

I am starting to think it is broken.

#define DB0 LATDbits.LATD4
#define DB1 LATDbits.LATD5
#define DB2 LATDbits.LATD6
#define DB3 LATDbits.LATD7
#define DB4 LATDbits.LATD8
#define DB5 LATDbits.LATD9
#define DB6 LATDbits.LATD10
#define DB7 LATDbits.LATD11

#define E   LATDbits.LATD3
#define RS  LATDbits.LATD0
#define RW  LATDbits.LATD1

void wait_k(int k)
{
while (k)
{ k -= 1; }
}

void    init(void)
{
LATDbits.LATD0 = 0;
LATDbits.LATD1 = 0;
LATDbits.LATD3 = 0;
LATDbits.LATD4 = 0;
LATDbits.LATD5 = 0;
LATDbits.LATD6 = 0;
LATDbits.LATD7 = 0;
LATDbits.LATD8 = 0;
LATDbits.LATD9 = 0;
LATDbits.LATD10 = 0;
LATDbits.LATD11 = 0;

TRISDbits.TRISD0 = 0;
TRISDbits.TRISD1 = 0;
TRISDbits.TRISD3 = 0;
TRISDbits.TRISD4 = 0;
TRISDbits.TRISD5 = 0;
TRISDbits.TRISD6 = 0;
TRISDbits.TRISD7 = 0;
TRISDbits.TRISD8 = 0;
TRISDbits.TRISD9 = 0;
TRISDbits.TRISD10 = 0;
TRISDbits.TRISD11 = 0;

}

int main ()
{
init();
wait_k(1000);
send(0, 0, 0b00110000);

wait_k(1000);
send(0, 0, 0b00110000);

wait_k(100);
send(0, 0, 0b00110000);

wait_k(1000);
send(0, 0, 0b00110000);

wait_k(1000);
send(0, 0, 0b00001000);

wait_k(1000);
send(0, 0, 0b00000001);

wait_k(1000);
send(0, 0, 0b00000111);

//----End Of INIT

wait_k(1000);
send(0, 0, 0b00111000);//Function Set

wait_k(1000);
send(0, 0, 0b00001110);// Display on

wait_k(1000);
send(0, 0, 0b00000110);//Entry mode set

wait_k(1000);
send(1, 0, 0b01010111);//Write 'W'

while(42);
return 0;
}

• why are you assigning RS, RW and E? ... your code does not do seem to do anything with them .... please post the complete code – jsotola May 31 '18 at 16:05
• Thank you for answering, I added the complete in the post. RS/E/RW are macros I set to make reading easier. – Mehdi Sabwat May 31 '18 at 16:42
• mcu model ? also keep it simple, all LATDbits and TRISDbits could be replaced by "LATD = 0; TRISD = 0;" – johnger May 31 '18 at 17:14
• the controller I use is : pic32mx340f512h. You are right for the LATDbits part, I chose to do it like that because it was easier that way for me to check and change the wiring – Mehdi Sabwat May 31 '18 at 21:05
• Thank you for answering @SamGibson. (a) I did use an oscilloscope to check the the delays and multimeter to check for voltage in the pins. I am planning on checking with the logic analyser in a few hours. b) we did not test our code in any other lcd, might be a good thing to do you are right c) we tested different delays, and different methods we discovered in forums. – Mehdi Sabwat Jun 1 '18 at 2:37