Naumanpak
Member level 2
Hi experts,
I have had a great experience with edaboard, you people have helped me a lot.
I have this LCD code for 16x4 module. But the problem is that every time I run it, i only get black boxes on row 1 and 3. Any suggestions??
thanks
I have had a great experience with edaboard, you people have helped me a lot.
I have this LCD code for 16x4 module. But the problem is that every time I run it, i only get black boxes on row 1 and 3. Any suggestions??
thanks
Code:
#include <regx51.h>
#define rs P2_5
#define rw P2_6
#define enable P2_7
#define lcd_port P0
#define XTAL 11.059200
#define XDIVIDER 12.0
#define delay_1ms 164 * (XTAL/XDIVIDER)
void delay(unsigned char);
void delay_ms(unsigned int);
void lcd_display(unsigned char);
void Lcd_Ini();
void lcd_command(unsigned char);
main()
{
unsigned int i;
lcd_command(0x01);
Lcd_Ini();
lcd_command(0x80);
lcd_display('L');
lcd_display('I');
lcd_display('N');
lcd_display('E');
lcd_display('1');
lcd_command(0xC0);
lcd_display('L');
lcd_display('I');
lcd_display('N');
lcd_display('E');
lcd_display('2');
lcd_command(0x94);
lcd_display('L');
lcd_display('I');
lcd_display('N');
lcd_display('E');
lcd_display('3');
lcd_command(0xd4);
lcd_display('L');
lcd_display('I');
lcd_display('N');
lcd_display('E');
lcd_display('4');
while(1){;}
}
void Lcd_Ini()
{
lcd_command(0x48);
delay_ms(30);
lcd_command(0x0c);
delay_ms(10);
lcd_command(0x06);
delay_ms(10);
lcd_command(0x01);
delay_ms(10);
}
void lcd_command(unsigned char command)
{
rw=0;
rs=0;
lcd_port=command;
enable=1;
enable=0;
delay_ms(5);
}
void lcd_display(unsigned char display)
{
rw=0;
rs=1;
lcd_port=display;
enable=1;
enable=0;
delay_ms(1);
}
void delay_ms(unsigned int i)
{
for(;i!=0x00;i--)
{
delay(delay_1ms);
}
}
void delay(unsigned char j)
{
for (;j!=0x00;j--)
{
}
}