View previous topic :: View next topic |
Author |
Message |
evaang2003 Guest
|
display text on lcd |
Posted: Tue Jun 09, 2009 9:24 pm |
|
|
Hi, I was trying to display text on lcd lmb162hba.
I try the 4 bit code but it didn't work.
THE CONNECTION IS AS FOLLOW:
pin D0=E
D1=RS
D2=R/W
D4=DB4
D5=DB5
D6=DB6
D7=DB7
The following is the code:
Code: |
#include<16f877a.h> //HEADER FILE;
#use delay(clock=4000000) //CRYSTAL FREQUENCY IS 20MHZ;
#include <lcd.c> //LCD DRIVER FILE;
#byte portb=0x06 //SPECIFY PORTB ADDRESS;
#byte trisb=0x86
#byte portd=0x08 //SPECIFY PORTD ADDRESS;
#byte trisd=0x88
main()
{
lcd_init();
set_tris_d(0x00); //PORTD IS CONFIGURED AS A O/P;
portd=0x00;
while(1)
{
lcd_gotoxy(1,1);
printf(lcd_putc,"welcome to"); //IN 1ST ROW "welcome to";
delay_ms(3);
lcd_gotoxy(1,2);
printf(lcd_putc,"LCD INTERFACING"); //IN 2ND ROW "LCD INTERFACING";
delay_ms(3);
}
}
|
Can anybody tell me the 8 bit mode and any wrong with 4 bit code? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
|
|
Posted: Tue Jun 09, 2009 10:06 pm |
|
|
First glaring error:
Quote: | #use delay(clock=4000000) //CRYSTAL FREQUENCY IS 20MHZ; |
You have a 20MHz crystal - you need to put 'clock=20000000'.
Quote: | #byte portb=0x06 //SPECIFY PORTB ADDRESS;
#byte trisb=0x86
#byte portd=0x08 //SPECIFY PORTD ADDRESS;
#byte trisd=0x88
| and Quote: | set_tris_d(0x00); //PORTD IS CONFIGURED AS A O/P;
portd=0x00; |
You need not put these. The compiler handles I/O direction on its own.
Rohit |
|
|
evaang2003 Guest
|
|
Posted: Tue Jun 09, 2009 11:03 pm |
|
|
erm, i use 4MHz crystal. just wrongly declare as 20MHz.
is it possible that the the lcd i use need to be driven by 8bit?
anybody got 8 bit lcd display text ccs code? |
|
|
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
|
|
Posted: Tue Jun 09, 2009 11:51 pm |
|
|
This is the datasheet for the LCD: http://www.topwaydisplay.com/Pub/Manual/LMB162HBC-Manual-Rev0.2.pdf
Page 4 says that it supports 4 bit mode.
Your LCD uses the ST7066U controller, which I believe (after a bit of googling :-) ) is pin and function compatible with the HD44780 controller. The datasheet of the module says that DB0-DB3 can be left NC in 4 bit mode. However, a few online forums mentioned that connecting them high worked in some cases, and grounding them worked in other cases. Maybe you can try that out?
Regarding an 8bit driver, here is something by Nisar Ahmed: http://www.ccsinfo.com/forum/viewtopic.php?t=38367&highlight=8bit
Rohit |
|
|
evaang2003 Guest
|
|
Posted: Wed Jun 10, 2009 8:17 pm |
|
|
i finally know what is the crucial error.
it was actually my compiler that generate rubbish hex code.
i now trying to get the new one.
thanks for everyone that have help me. |
|
|
|