Naumanpak
Member level 2
Experts,
I have this lcd command function but cannot initialize the lcd in 4 bit mode. 8 bit was done without any problems but am struggling to initialize LCD in 4 bit mode.
where,
rs PORTB.RB2
rw PORTB.RB1
enable PORTB.RB0
and D7-D4 are connected to RB&-RB4
thanks
I have this lcd command function but cannot initialize the lcd in 4 bit mode. 8 bit was done without any problems but am struggling to initialize LCD in 4 bit mode.
Code:
void lcd_command(unsigned char command)
{
rw=0;
delay_ms(1);
rs=1;
PORTB = PORTB&0x0F;
PORTB = PORTB|(command&0xF0);
enable=1;
delay_ms(1);
enable=0;
PORTB = PORTB&0x0F;
PORTB = PORTB|((command<<4)&(0xF0));
enable=1;
delay_ms(1);
enable=0;
}
where,
rs PORTB.RB2
rw PORTB.RB1
enable PORTB.RB0
and D7-D4 are connected to RB&-RB4
thanks