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

LCD.C Driver Question

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



Joined: 23 Nov 2005
Posts: 4

View user's profile Send private message

LCD.C Driver Question
PostPosted: Wed Nov 23, 2005 7:30 pm     Reply with quote

I'm a TOTAL newbie to the PIC 16f877. the LCD driver provided by CCS is to be used on PORT B and PORT D (see below). BUT, I'm currently using PORT B for something else. Can I switch to PORT C? From the 16f877 datasheet I noticed that there is no 'option_reg' for PORT C, are there any alternatives? HELP!! Thanks.
--------------------------------------------------------------------
#if defined(__PCH__)
#if defined use_portb_lcd
#byte lcd = 0xF81 // This puts the entire structure
#else
#byte lcd = 0xF83 // This puts the entire structure
#endif
#else
#if defined use_portb_lcd
#byte lcd = 6 // on to port B (at address 6)
#else
#byte lcd = 8 // on to port D (at address 8)
#endif
#endif

#if defined use_portb_lcd
#define set_tris_lcd(x) set_tris_b(x)
#else
#define set_tris_lcd(x) set_tris_d(x)
#endif
-------------------------
Also, my LCD has 4 lines. Can the code be modified to:

#define lcd_type 4
#define lcd_line_two 0x40 // LCD RAM address for the 2nd line
#define lcd_line_three 0x10 //LCD RAM address for 3rd line
#define lcd_line_four 0x50 //LCD RAM address for 4th line

void lcd_gotoxy( BYTE x, BYTE y)
{
BYTE Data;
if(y=2)
Data=lcd_line_two;
else if (y=3)
Data=lcd_line_three;
else if (y=4)
Data=lcd_line_four;
else
Data=0;
Data+=x-1;
lcd_send_byte(0,0x80|Data);
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Nov 23, 2005 11:07 pm     Reply with quote

Quote:
Can I switch to PORT C?

CCS has a 4x20 lcd driver, called LCD420.C, and it's in this folder:
C:\Program Files\PICC\Drivers

It's setup to run on Port B, but you can make the following changes
to let it run on Port C.

1. Change the lcd port address statement from:
#byte lcd = 6
to
#byte lcd = 7 // Port C for the 16F877

2. There are three places where it uses the set_tris_b() function.
Just change it to "set_tris_c" in each statement, and leave everything
else the same.
noplacelikehome



Joined: 23 Nov 2005
Posts: 4

View user's profile Send private message

PostPosted: Sun Nov 27, 2005 1:17 am     Reply with quote

Thanks!
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