I have been struggling for two weeks to get a SPL780D based LCD 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
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 :
[![enter image description here][1]][1]
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.
lcd reference MC42005A6W-FPTLW3-V2MC42005A6W-FPTLW3-V2
Size : 20*4
[1]: https://i.stack.imgur.com/1NdEo.png
Adding the complete code below:
#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;
}