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 CCS Technical Support

need help with lcd? help please!

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



Joined: 25 Jan 2010
Posts: 35

View user's profile Send private message MSN Messenger

need help with lcd? help please!
PostPosted: Mon Mar 01, 2010 7:35 am     Reply with quote

Hello everyone. I use a pic16f876 and an lcd. My aim is to print some wtitings on lcd. I can do it on Proteus but I can't realize it although I think my connections are true. I connect Enable to pin b0, Register Select to B1, Read/Write to B2 and DB7 - b7, DB6 - b6 , DB5 - b5, DB4 - b4 and I connect Vdd and Vss. I also connect V0 to ground. But it did not work. Here is my code. But I have some misunderstandings on code?
What should be the values of #define LCD_DATA_PORT 4, LCD_TRIS_LOCATION 0x86, and #define LCD_TYPE 2? Also what are they for? Do I need to use lcd_setup or lcd_load functions??? If I need can anyone correct the code???
Please help...

Here is the code:

Code:
#include <16F876.h>
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES RC                       //Resistor/Capacitor Osc with CLKOUT
#FUSES NOPUT                    //No Power Up Timer
#FUSES PROTECT                  //Code protected from reads
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD                    //No EE protection
#FUSES NOWRT                    //Program memory not write protected
#FUSES NODEBUG                  //No Debug mode for ICD

#use delay(clock=4000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)

#define use_portb_lcd TRUE
#define LCD_ENABLE_PIN PIN_B0
#define LCD_RS_PIN PIN_B1
#define LCD_RW_PIN PIN_B2
#define LCD_DATA_PORT 4                 //what should this value be?
#define LCD_TYPE 2                           //is it 2 columns? or rows?
#define LCD_TRIS_LOCATION 0x86     //what should this value be?
#include <lcd.c>


void main()
{
   lcd_init();

   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_spi(SPI_SS_DISABLED);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);

   set_tris_b(0x00);
   while(1)
   {
     lcd_gotoxy(1,1);
     printf(lcd_putc,"Hello");
     lcd_gotoxy(1,2);
     printf(lcd_putc,"World!");
     delay_ms(5000);
   }

}

_________________
compiler version: 4.105
pic: 16f876
clock frequency: 4MHz
husam



Joined: 17 Feb 2010
Posts: 10
Location: jordan

View user's profile Send private message

PostPosted: Mon Mar 01, 2010 8:00 am     Reply with quote

hi ,
try this proteus example
http://rapidshare.com/files/357456124/LCD_Connection.rar.html
memoally



Joined: 25 Jan 2010
Posts: 35

View user's profile Send private message MSN Messenger

PostPosted: Mon Mar 01, 2010 11:32 am     Reply with quote

First of all thank you husam, for your answer. I have not tried this yet
but I am trying to learn where the mistake is with my code. Should I add:
Code:

#define LCD_DB4   PIN_B4
#define LCD_DB5   PIN_B5
#define LCD_DB6   PIN_B6
#define LCD_DB7   PIN_B7

#define LCD_ENABLE_PIN PIN_B0
#define LCD_RS_PIN PIN_B1
#define LCD_RW_PIN PIN_B2   ?

I also want to learn what is ''#define LCD_TRIS_LOCATION'' and ''#define LCD_DATA_PORT ''. What are they for? Is lcd_data_port
means 4 bit or 8 bit operation? Could you correct my code please?
Or anyone, please...
_________________
compiler version: 4.105
pic: 16f876
clock frequency: 4MHz
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Mar 01, 2010 12:29 pm     Reply with quote

Don't use that LCD driver. Use the Flex driver:
http://www.ccsinfo.com/forum/viewtopic.php?t=24661


Quote:

I also want to learn what is ''#define LCD_TRIS_LOCATION''
and ''#define LCD_DATA_PORT ''. What are they for? Is lcd_data_port

With the Flex LCD driver, you don't have to worry about any of this
stuff. All you need to do is #define the pins.
memoally



Joined: 25 Jan 2010
Posts: 35

View user's profile Send private message MSN Messenger

PostPosted: Mon Mar 01, 2010 4:12 pm     Reply with quote

but i dont have it,and i am supposed to use this lcd :( i dont know the exact producer or firm,but on the back side there is a writing HY-0802B-001-R,i have a datasheet of this,if you want i can share it...
_________________
compiler version: 4.105
pic: 16f876
clock frequency: 4MHz
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Mar 01, 2010 4:18 pm     Reply with quote

Quote:
but i dont have it

What do you mean by this ? The Flex driver is available at the link that
I posted. Just click on it. Just do it.
memoally



Joined: 25 Jan 2010
Posts: 35

View user's profile Send private message MSN Messenger

PostPosted: Mon Mar 01, 2010 4:25 pm     Reply with quote

sorry,i told wrongly,i guess.this is not a training,or exercise,in my work there is a project about pic,i get the job recently,and the specifications were determined long time ago,also components are bought :( so i have to use this lcd Smile i am trying to test lcd for a few days,but i cant make it to write anything on lcd,my connections are true,i know it,but there may be some mistakes on that simple code.for example i don't know how to choose 4 bit or 8 bit data operation,i mean the exact code for it, (#define ...???...).so i wanted your help Smile
_________________
compiler version: 4.105
pic: 16f876
clock frequency: 4MHz
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