CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

display text on lcd

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
evaang2003
Guest







display text on lcd
PostPosted: Tue Jun 09, 2009 9:24 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jun 09, 2009 9:52 pm     Reply with quote

Try the Flex driver. It's a 4-bit driver and it should work.
http://www.ccsinfo.com/forum/viewtopic.php?t=24661
Rohit de Sa



Joined: 09 Nov 2007
Posts: 282
Location: India

View user's profile Send private message Visit poster's website

PostPosted: Tue Jun 09, 2009 10:06 pm     Reply with quote

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







PostPosted: Tue Jun 09, 2009 11:03 pm     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Tue Jun 09, 2009 11:51 pm     Reply with quote

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







PostPosted: Wed Jun 10, 2009 8:17 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group